enhance: improve commit page header (#39229)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-09-06 11:27:04 +02:00
committed by GitHub
co-authored by wxiaoguang
parent 7c280c0ce6
commit 87d5497da0
10 changed files with 54 additions and 108 deletions
+4 -11
View File
@@ -177,6 +177,10 @@ func (c *Commit) AllAuthorIdentities() []*CommitIdentity {
return c.allAuthors
}
func (c *Commit) CommitterIsAuthor() bool {
return c.Committer.Name == c.Author.Name && c.Committer.Email == c.Author.Email
}
// Git identities are not RFC 5322 addresses: net/mail rejects names like "dependabot[bot]", so fall back to the angle-addr.
func parseCommitIdentityValue(value string) (name, email string) {
if addr, err := mail.ParseAddress(value); err == nil {
@@ -188,14 +192,3 @@ func parseCommitIdentityValue(value string) (name, email string) {
}
return strings.TrimSpace(value[:begin]), strings.TrimSpace(value[begin+1 : end])
}
func (c *Commit) CoAuthorIdentities() (coAuthors []*CommitIdentity) {
all := c.AllAuthorIdentities()
if len(all) == 0 {
return nil
}
if all[0].role == commitIdentityRoleAuthor {
return all[1:]
}
return all
}