Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions domain/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
22 changes: 21 additions & 1 deletion services/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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") {
Expand Down
6 changes: 5 additions & 1 deletion services/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down