Skip to content

Commit

Permalink
Fix duplicate co-author in squashed merge commit messages (go-gitea#3…
Browse files Browse the repository at this point in the history
…3020)

Fix: go-gitea#31980

---------

Co-authored-by: wxiaoguang <[email protected]>
  • Loading branch information
hiifong and wxiaoguang authored Dec 30, 2024
1 parent fe32ffe commit a871688
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion services/pull/merge_squash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit a871688

Please sign in to comment.