-3
appview/repo/repo_util.go
-3
appview/repo/repo_util.go
+26
types/commit.go
+26
types/commit.go
···
5
"encoding/json"
6
"fmt"
7
"maps"
8
+
"regexp"
9
"strings"
10
11
"github.com/go-git/go-git/v5/plumbing"
···
167
168
return payload.String()
169
}
170
+
171
+
var (
172
+
coAuthorRegex = regexp.MustCompile(`(?im)^Co-authored-by:\s*(.+?)\s*<([^>]+)>`)
173
+
)
174
+
175
+
func (commit *Commit) CoAuthors() []object.Signature {
176
+
var coAuthors []object.Signature
177
+
178
+
matches := coAuthorRegex.FindAllStringSubmatch(commit.Message, -1)
179
+
180
+
for _, match := range matches {
181
+
if len(match) >= 3 {
182
+
name := strings.TrimSpace(match[1])
183
+
email := strings.TrimSpace(match[2])
184
+
185
+
coAuthors = append(coAuthors, object.Signature{
186
+
Name: name,
187
+
Email: email,
188
+
When: commit.Committer.When,
189
+
})
190
+
}
191
+
}
192
+
193
+
return coAuthors
194
+
}