fix: incorrect co-author detection on commit page (#38386)

The commit page built its "co-authored by" list from
`AllParticipantIdentities()[1:]`, which only drops the author and leaves
the committer in the list even though the committer is already shown
separately as "committed by". This caused the committer to be wrongly
rendered as a co-author (issue #38384): a commit authored by
`silverwind`, committed by `bircni`, with a `Co-authored-by: silverwind`
trailer displayed "co-authored by bircni" instead of the actual trailer
identity. This adds a `Commit.CoAuthorIdentities()` method that excludes
both the author and the committer, uses it on the commit page, and
covers the fix with a regression test.

Closes #38384
This commit is contained in:
bircni
2026-07-09 22:31:14 +02:00
committed by GitHub
parent 761470c01d
commit 27e33b7ba1
3 changed files with 54 additions and 1 deletions

View File

@@ -131,3 +131,17 @@ func (c *Commit) AllParticipantIdentities() []*CommitIdentity {
}
return c.allParticipants
}
// CoAuthorIdentities returns the commit's co-authors: the participants without the
// author and the committer, which are already displayed separately. This avoids
// surfacing the committer as a "co-author" (see issue #38384).
func (c *Commit) CoAuthorIdentities() []*CommitIdentity {
var ret []*CommitIdentity
for _, p := range c.AllParticipantIdentities()[1:] { // index 0 is always the author
if c.Committer.Email != "" && strings.EqualFold(p.Email, c.Committer.Email) {
continue
}
ret = append(ret, p)
}
return ret
}