Skip to content

Commit ad19456

Browse files
committed
BUG: fix Merge regex and log history end ("From")
1 parent 68aa057 commit ad19456

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@ jobs:
3939
# Runs a set of commands using the runners shell
4040
- name: Run a multi-line script
4141
run: |
42-
export
4342
git clone -b git_envs https://github.com/aiharos/github-actions.git
4443
cd github-actions/check-commit; go run check.go "../../."

check-commit/check.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ func readGitEnvironment() (*gitEnv, error) {
212212
}
213213

214214
var ref, base string
215+
215216
for _, vars := range knownVars {
216217
event := os.Getenv(vars.EventVar)
217218
ref = os.Getenv(vars.RefVar)
@@ -288,7 +289,7 @@ func getCommitSubjects(repo *git.Repository, repoEnv *gitEnv) ([]string, error)
288289
}
289290

290291
logOptions := new(git.LogOptions)
291-
logOptions.From = *hashes[1]
292+
logOptions.From = *hashes[0]
292293

293294
cIter, err := repo.Log(logOptions)
294295
if err != nil {
@@ -297,12 +298,13 @@ func getCommitSubjects(repo *git.Repository, repoEnv *gitEnv) ([]string, error)
297298

298299
var subjects []string
299300

300-
gitlabMergeRegex := regexp.MustCompile("Merge %s into %s")
301+
gitlabMergeRegex := regexp.MustCompile(`Merge \w{40} into \w{40}`)
301302

302303
err = cIter.ForEach(func(c *object.Commit) error {
303304
if c.Hash == mergeBase[0].Hash {
304305
return ErrReachedMergeBase
305306
}
307+
log.Printf("collected commit hash %s", c.Hash)
306308

307309
if !(repoEnv.EnvName == "Github" && repoEnv.Event == "pull_request" && gitlabMergeRegex.Match([]byte(c.Message))) {
308310
// ignore github pull request commits with subject "Merge x into y", these get added automatically by github

0 commit comments

Comments
 (0)