-3
appview/repo/repo_util.go
-3
appview/repo/repo_util.go
···
1
1
package repo
2
2
3
3
import (
4
-
"regexp"
5
4
"slices"
6
5
"sort"
7
6
"strings"
···
9
8
"tangled.org/core/appview/db"
10
9
"tangled.org/core/appview/models"
11
10
"tangled.org/core/types"
12
-
13
-
"github.com/go-git/go-git/v5/plumbing/object"
14
11
)
15
12
16
13
func sortFiles(files []types.NiceTree) {
+26
types/commit.go
+26
types/commit.go
···
5
5
"encoding/json"
6
6
"fmt"
7
7
"maps"
8
+
"regexp"
8
9
"strings"
9
10
10
11
"github.com/go-git/go-git/v5/plumbing"
···
166
167
167
168
return payload.String()
168
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
+
}