aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhiifong <i@hiif.ong>2024-12-31 03:03:21 +0800
committerGitHub <noreply@github.com>2024-12-30 19:03:21 +0000
commita87168869a4ceffb2a3d84986640da357b0793cf (patch)
tree9ceaab9d60026ed4cc7326315e45c821da3b54e2
parentfe32ffe1819038f7edadd749b7c1ef84667d1c81 (diff)
downloadgitea-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.go6
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).