Skip to content

Commit a67bbb5

Browse files
authored
fix: resolve git authors to GitHub usernames in release notes (#3)
## Summary - Extract GitHub usernames from noreply email addresses in git commits - Format contributors as @username links in release notes - Works for both AI-generated and git fallback release notes ## Test plan - [ ] Verify `go test ./...` passes - [ ] Trigger a release and check contributors section shows @username links
1 parent af0d021 commit a67bbb5

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

domain/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type DetailedCommit struct {
99
Hash string `json:"hash"`
1010
Message string `json:"message"`
1111
Author string `json:"author"`
12+
AuthorEmail string `json:"author_email"`
1213
Date string `json:"date"`
1314
FilesChanged []string `json:"files_changed"`
1415
FileCount int `json:"file_count"`

services/git.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,20 @@ func (g *GitService) GetCommitDetails(commits []domain.CommitInfo) ([]domain.Det
128128
Message: c.Message,
129129
}
130130

131-
// Get author and date
131+
// Get author name, email, and date
132132
authorOut, err := g.runGit("show", c.Hash, "--format=%an", "--no-patch")
133133
if err == nil {
134134
dc.Author = strings.TrimSpace(authorOut)
135135
}
136136

137+
emailOut, err := g.runGit("show", c.Hash, "--format=%ae", "--no-patch")
138+
if err == nil {
139+
dc.AuthorEmail = strings.TrimSpace(emailOut)
140+
if ghUser := extractGitHubUser(dc.AuthorEmail); ghUser != "" {
141+
dc.Author = "@" + ghUser
142+
}
143+
}
144+
137145
dateOut, err := g.runGit("show", c.Hash, "--format=%ci", "--no-patch")
138146
if err == nil {
139147
dc.Date = strings.TrimSpace(dateOut)
@@ -273,6 +281,18 @@ func (g *GitService) touchesIgnored(files, ignoreList []string) bool {
273281
return false
274282
}
275283

284+
func extractGitHubUser(email string) string {
285+
if !strings.HasSuffix(email, "@users.noreply.github.com") {
286+
return ""
287+
}
288+
local := strings.TrimSuffix(email, "@users.noreply.github.com")
289+
// Handle id+username format (e.g. 12345+username@users.noreply.github.com)
290+
if idx := strings.Index(local, "+"); idx >= 0 {
291+
return local[idx+1:]
292+
}
293+
return local
294+
}
295+
276296
func splitLines(s string) []string {
277297
var lines []string
278298
for _, line := range strings.Split(s, "\n") {

services/prompt.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,11 @@ func (p *PromptService) GenerateGitFallbackNotes(
380380
authors := uniqueAuthors(detailedCommits)
381381
if len(authors) > 0 {
382382
for _, a := range authors {
383-
notes.WriteString(fmt.Sprintf("- %s\n", a))
383+
if strings.HasPrefix(a, "@") {
384+
notes.WriteString(fmt.Sprintf("- [%s](https://github.com/%s)\n", a, a[1:]))
385+
} else {
386+
notes.WriteString(fmt.Sprintf("- %s\n", a))
387+
}
384388
}
385389
} else {
386390
notes.WriteString("- N/A\n")

0 commit comments

Comments
 (0)