Skip to content

Commit

Permalink
fix: make merge commit regex more lenient
Browse files Browse the repository at this point in the history
- in order to make maintenance easier it would be better to make merge message regex lenient

Closes #101
  • Loading branch information
fallion committed Sep 12, 2019
1 parent 0555f1b commit 7e9ee98
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions pkg/text/is_merge_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,11 @@ import (
"regexp"
)

var mergeCommitRegex = regexp.MustCompile(`^Merge commit '(?P<hash>\S+)'`)
var mergeBranchRegex = regexp.MustCompile(`^Merge branch '(?P<incoming>\w+)' into (?P<current>\S+)`)
var mergePRRegex = regexp.MustCompile(`^Merge pull request (?P<incoming>#\d+) from (?P<current>\S+)`)
var kodiakMergeBranchRegex = regexp.MustCompile(`^Merge (?P<incoming>\w+) into (?P<current>\S+)`)
var mergeCommitRegex = regexp.MustCompile(`^Merge .+`)

// IsMergeCommit tests message string against expected format of a merge commit and returns true/false based on it
func IsMergeCommit(message string) bool {
mergeCommitMatch := mergeCommitRegex.FindStringSubmatch(message)

mergeBranchMatch := mergeBranchRegex.FindStringSubmatch(message)

mergePRMatch := mergePRRegex.FindStringSubmatch(message)

kodiakMergeBranchMatch := kodiakMergeBranchRegex.FindStringSubmatch(message)

if mergeCommitMatch != nil || mergeBranchMatch != nil || mergePRMatch != nil || kodiakMergeBranchMatch != nil {
return true
}

return false
return mergeCommitMatch != nil
}

0 comments on commit 7e9ee98

Please sign in to comment.