Skip to content

Commit b5a9ee9

Browse files
authored
Make Co-committed-by and co-authored-by trailers optional (#17848)
This PR adds another option to app.ini make co-committed-by and co-authored-by trailers optional on a per server basis. Fix #17194 Signed-off-by: Andrew Thornton <art27@cantab.net>
1 parent 3fec2cb commit b5a9ee9

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

custom/conf/app.example.ini

+3
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,9 @@ PATH =
900900
;;
901901
;; In default merge messages only include approvers who are official
902902
;DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY = true
903+
;;
904+
;; Add co-authored-by and co-committed-by trailers if committer does not match author
905+
;ADD_CO_COMMITTER_TRAILERS = true
903906

904907
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
905908
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
9898
- `DEFAULT_MERGE_MESSAGE_MAX_APPROVERS`: **10**: In default merge messages limit the number of approvers listed as `Reviewed-by:`. Set to `-1` to include all.
9999
- `DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY`: **true**: In default merge messages only include approvers who are officially allowed to review.
100100
- `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES`: **false**: In default squash-merge messages include the commit message of all commits comprising the pull request.
101+
- `ADD_CO_COMMITTER_TRAILERS`: **true**: Add co-authored-by and co-committed-by trailers to merge commit messages if committer does not match author.
101102

102103
### Repository - Issue (`repository.issue`)
103104

modules/setting/repository.go

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ var (
7676
DefaultMergeMessageMaxApprovers int
7777
DefaultMergeMessageOfficialApproversOnly bool
7878
PopulateSquashCommentWithCommitMessages bool
79+
AddCoCommitterTrailers bool
7980
} `ini:"repository.pull-request"`
8081

8182
// Issue Setting
@@ -196,6 +197,7 @@ var (
196197
DefaultMergeMessageMaxApprovers int
197198
DefaultMergeMessageOfficialApproversOnly bool
198199
PopulateSquashCommentWithCommitMessages bool
200+
AddCoCommitterTrailers bool
199201
}{
200202
WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
201203
// Same as GitHub. See
@@ -208,6 +210,7 @@ var (
208210
DefaultMergeMessageMaxApprovers: 10,
209211
DefaultMergeMessageOfficialApproversOnly: true,
210212
PopulateSquashCommentWithCommitMessages: false,
213+
AddCoCommitterTrailers: true,
211214
},
212215

213216
// Issue settings

services/pull/merge.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func rawMerge(pr *models.PullRequest, doer *user_model.User, mergeStyle models.M
359359
return "", fmt.Errorf("git commit [%s:%s -> %s:%s]: %v\n%s\n%s", pr.HeadRepo.FullName(), pr.HeadBranch, pr.BaseRepo.FullName(), pr.BaseBranch, err, outbuf.String(), errbuf.String())
360360
}
361361
} else {
362-
if committer != sig {
362+
if setting.Repository.PullRequest.AddCoCommitterTrailers && committer.String() != sig.String() {
363363
// add trailer
364364
message += fmt.Sprintf("\nCo-authored-by: %s\nCo-committed-by: %s\n", sig.String(), sig.String())
365365
}

0 commit comments

Comments
 (0)