@@ -8,11 +8,21 @@ import (
8
8
)
9
9
10
10
var (
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])+)` )
14
16
)
15
17
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
+
16
26
type DefaultCommitAnalyzer struct {}
17
27
18
28
func (da * DefaultCommitAnalyzer ) Init (m map [string ]string ) error {
@@ -34,6 +44,9 @@ func (da *DefaultCommitAnalyzer) analyzeSingleCommit(rawCommit *semrel.RawCommit
34
44
Change : & semrel.Change {},
35
45
Annotations : rawCommit .Annotations ,
36
46
}
47
+ c .Annotations ["mentioned_issues" ] = extractMentions (mentionedIssuesPattern , rawCommit .RawMessage )
48
+ c .Annotations ["mentioned_users" ] = extractMentions (mentionedUsersPattern , rawCommit .RawMessage )
49
+
37
50
found := commitPattern .FindAllStringSubmatch (c .Raw [0 ], - 1 )
38
51
if len (found ) < 1 {
39
52
return c
0 commit comments