diff --git a/domain/types.go b/domain/types.go index 6783f30..bff1cbe 100644 --- a/domain/types.go +++ b/domain/types.go @@ -9,6 +9,7 @@ type DetailedCommit struct { Hash string `json:"hash"` Message string `json:"message"` Author string `json:"author"` + AuthorEmail string `json:"author_email"` Date string `json:"date"` FilesChanged []string `json:"files_changed"` FileCount int `json:"file_count"` diff --git a/services/git.go b/services/git.go index 26e6876..37efadb 100644 --- a/services/git.go +++ b/services/git.go @@ -128,12 +128,20 @@ func (g *GitService) GetCommitDetails(commits []domain.CommitInfo) ([]domain.Det Message: c.Message, } - // Get author and date + // Get author name, email, and date authorOut, err := g.runGit("show", c.Hash, "--format=%an", "--no-patch") if err == nil { dc.Author = strings.TrimSpace(authorOut) } + emailOut, err := g.runGit("show", c.Hash, "--format=%ae", "--no-patch") + if err == nil { + dc.AuthorEmail = strings.TrimSpace(emailOut) + if ghUser := extractGitHubUser(dc.AuthorEmail); ghUser != "" { + dc.Author = "@" + ghUser + } + } + dateOut, err := g.runGit("show", c.Hash, "--format=%ci", "--no-patch") if err == nil { dc.Date = strings.TrimSpace(dateOut) @@ -273,6 +281,18 @@ func (g *GitService) touchesIgnored(files, ignoreList []string) bool { return false } +func extractGitHubUser(email string) string { + if !strings.HasSuffix(email, "@users.noreply.github.com") { + return "" + } + local := strings.TrimSuffix(email, "@users.noreply.github.com") + // Handle id+username format (e.g. 12345+username@users.noreply.github.com) + if idx := strings.Index(local, "+"); idx >= 0 { + return local[idx+1:] + } + return local +} + func splitLines(s string) []string { var lines []string for _, line := range strings.Split(s, "\n") { diff --git a/services/prompt.go b/services/prompt.go index aebbdaf..eb6d2be 100644 --- a/services/prompt.go +++ b/services/prompt.go @@ -380,7 +380,11 @@ func (p *PromptService) GenerateGitFallbackNotes( authors := uniqueAuthors(detailedCommits) if len(authors) > 0 { for _, a := range authors { - notes.WriteString(fmt.Sprintf("- %s\n", a)) + if strings.HasPrefix(a, "@") { + notes.WriteString(fmt.Sprintf("- [%s](https://github.com/%s)\n", a, a[1:])) + } else { + notes.WriteString(fmt.Sprintf("- %s\n", a)) + } } } else { notes.WriteString("- N/A\n")