1
1
mirror of https://github.com/go-gitea/gitea synced 2025-01-07 00:14:25 +00:00

Fix duplicate co-author in squashed merge commit messages (#33020) (#33054)

This commit is contained in:
Giteabot 2024-12-31 11:04:47 +08:00 committed by GitHub
parent 968c04c7da
commit 96fff862dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@ package pull
import (
"fmt"
"strings"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
@ -66,7 +67,10 @@ func doMergeStyleSquash(ctx *mergeContext, message string) error {
if setting.Repository.PullRequest.AddCoCommitterTrailers && ctx.committer.String() != sig.String() {
// add trailer
message += fmt.Sprintf("\nCo-authored-by: %s\nCo-committed-by: %s\n", sig.String(), sig.String())
if !strings.Contains(message, fmt.Sprintf("Co-authored-by: %s", sig.String())) {
message += fmt.Sprintf("\nCo-authored-by: %s", sig.String())
}
message += fmt.Sprintf("\nCo-committed-by: %s\n", sig.String())
}
cmdCommit := git.NewCommand(ctx, "commit").
AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email).