diff options
author | hiifong <i@hiif.ong> | 2024-12-31 03:03:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-30 19:03:21 +0000 |
commit | a87168869a4ceffb2a3d84986640da357b0793cf (patch) | |
tree | 9ceaab9d60026ed4cc7326315e45c821da3b54e2 | |
parent | fe32ffe1819038f7edadd749b7c1ef84667d1c81 (diff) | |
download | gitea-a87168869a4ceffb2a3d84986640da357b0793cf.tar.gz gitea-a87168869a4ceffb2a3d84986640da357b0793cf.zip |
Fix duplicate co-author in squashed merge commit messages (#33020)
Fix: #31980
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
-rw-r--r-- | services/pull/merge_squash.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/services/pull/merge_squash.go b/services/pull/merge_squash.go index 8f8a5d82e7..7258671888 100644 --- a/services/pull/merge_squash.go +++ b/services/pull/merge_squash.go @@ -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" @@ -65,7 +66,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). |