mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-11 16:22:41 +00:00
Backport #38386 by @bircni 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 Co-authored-by: bircni <bircni@icloud.com>
This commit is contained in:
@@ -80,3 +80,42 @@ func TestCommitMessageAllParticipantIdentities(t *testing.T) {
|
||||
assert.Equal(t, c.participant, c.commit.AllParticipantIdentities())
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommitMessageCoAuthorIdentities(t *testing.T) {
|
||||
sig := func(n, e string) *Signature { return &Signature{Name: n, Email: e} }
|
||||
idt := func(n, e string) *CommitIdentity { return &CommitIdentity{Name: n, Email: e} }
|
||||
cases := []struct {
|
||||
commit *Commit
|
||||
coAuthors []*CommitIdentity
|
||||
}{
|
||||
{
|
||||
// a genuine co-author (neither author nor committer) is reported
|
||||
&Commit{
|
||||
Author: sig("a", "a@m.com"), Committer: sig("c", "c@m.com"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Co-authored-by: x <x@m.com>"},
|
||||
},
|
||||
[]*CommitIdentity{idt("x", "x@m.com")},
|
||||
},
|
||||
{
|
||||
// the committer is shown separately as "committed by", so it must
|
||||
// not appear as a co-author even though it is a participant
|
||||
&Commit{
|
||||
Author: sig("a", "a@m.com"), Committer: sig("c", "c@m.com"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Co-authored-by: c <c@m.com>"},
|
||||
},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
// regression for #38384: a Co-authored-by trailer naming the author
|
||||
// must not cause the committer to be surfaced as the co-author
|
||||
&Commit{
|
||||
Author: sig("silverwind", "me@silverwind.io"), Committer: sig("bircni", "bircni@icloud.com"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Co-authored-by: silverwind <me@silverwind.io>"},
|
||||
},
|
||||
nil,
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
assert.Equal(t, c.coAuthors, c.commit.CoAuthorIdentities())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user