Skip to content

Commit

Permalink
Fix #4: False positive for commit messages that matches the pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrunwald committed Sep 30, 2015
1 parent e91b9c5 commit 9188a94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ func GetIssuesOutOfMessage(issueMessage string) []string {
// Normally i would use
// ((?<!([A-Z]{1,10})-?)[A-Z]+-\d+)
// See http://stackoverflow.com/questions/26771592/negative-look-ahead-go-regular-expressions
re := regexp.MustCompile("([A-Z]+-\\d+)")
return re.FindAllString(issueMessage, -1)
var issues []string
re := regexp.MustCompile("([A-Z]+)-(\\d+)")

parts := re.FindAllStringSubmatch(issueMessage, -1)
for _, v := range parts {
// If the issue number > 0 (to avoid matches for PSR-0)
if v[2] > "0" {
issues = append(issues, v[0])
}
}

return issues
}
1 change: 1 addition & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func TestGetIssuesOutOfMessage(t *testing.T) {
{"WEB-22861 remove authentication prod build for now", []string{"WEB-22861"}},
{"[WEB-22861] remove authentication prod build for now", []string{"WEB-22861"}},
{"WEB-4711 SYS-1234 PRD-5678 remove authentication prod build for now", []string{"WEB-4711", "SYS-1234", "PRD-5678"}},
{"[SCC-27] Replace deprecated autoloader strategy PSR-0 with PSR-4", []string{"SCC-27", "PSR-4"}},
{"TASKLESS: Removes duplicated comment code.", nil},
}

Expand Down

0 comments on commit 9188a94

Please sign in to comment.