@@ -8,11 +8,21 @@ import (
88)
99
1010var (
11- CAVERSION = "dev"
12- commitPattern = regexp .MustCompile (`^(\w*)(?:\((.*)\))?(\!)?\: (.*)$` )
13- breakingPattern = regexp .MustCompile ("BREAKING CHANGES?" )
11+ CAVERSION = "dev"
12+ commitPattern = regexp .MustCompile (`^(\w*)(?:\((.*)\))?(\!)?\: (.*)$` )
13+ breakingPattern = regexp .MustCompile ("BREAKING CHANGES?" )
14+ mentionedIssuesPattern = regexp .MustCompile (`#(\d+)` )
15+ mentionedUsersPattern = regexp .MustCompile (`(?i)@([a-z\d]([a-z\d]|-[a-z\d])+)` )
1416)
1517
18+ func extractMentions (re * regexp.Regexp , s string ) string {
19+ ret := make ([]string , 0 )
20+ for _ , m := range re .FindAllStringSubmatch (s , - 1 ) {
21+ ret = append (ret , m [1 ])
22+ }
23+ return strings .Join (ret , "," )
24+ }
25+
1626type DefaultCommitAnalyzer struct {}
1727
1828func (da * DefaultCommitAnalyzer ) Init (m map [string ]string ) error {
@@ -34,6 +44,9 @@ func (da *DefaultCommitAnalyzer) analyzeSingleCommit(rawCommit *semrel.RawCommit
3444 Change : & semrel.Change {},
3545 Annotations : rawCommit .Annotations ,
3646 }
47+ c .Annotations ["mentioned_issues" ] = extractMentions (mentionedIssuesPattern , rawCommit .RawMessage )
48+ c .Annotations ["mentioned_users" ] = extractMentions (mentionedUsersPattern , rawCommit .RawMessage )
49+
3750 found := commitPattern .FindAllStringSubmatch (c .Raw [0 ], - 1 )
3851 if len (found ) < 1 {
3952 return c
0 commit comments