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>tags/v1.16.0-rc1
;; | ;; | ||||
;; In default merge messages only include approvers who are official | ;; In default merge messages only include approvers who are official | ||||
;DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY = true | ;DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY = true | ||||
;; | |||||
;; Add co-authored-by and co-committed-by trailers if committer does not match author | |||||
;ADD_CO_COMMITTER_TRAILERS = true | |||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
- `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. | - `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. | ||||
- `DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY`: **true**: In default merge messages only include approvers who are officially allowed to review. | - `DEFAULT_MERGE_MESSAGE_OFFICIAL_APPROVERS_ONLY`: **true**: In default merge messages only include approvers who are officially allowed to review. | ||||
- `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES`: **false**: In default squash-merge messages include the commit message of all commits comprising the pull request. | - `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES`: **false**: In default squash-merge messages include the commit message of all commits comprising the pull request. | ||||
- `ADD_CO_COMMITTER_TRAILERS`: **true**: Add co-authored-by and co-committed-by trailers to merge commit messages if committer does not match author. | |||||
### Repository - Issue (`repository.issue`) | ### Repository - Issue (`repository.issue`) | ||||
DefaultMergeMessageMaxApprovers int | DefaultMergeMessageMaxApprovers int | ||||
DefaultMergeMessageOfficialApproversOnly bool | DefaultMergeMessageOfficialApproversOnly bool | ||||
PopulateSquashCommentWithCommitMessages bool | PopulateSquashCommentWithCommitMessages bool | ||||
AddCoCommitterTrailers bool | |||||
} `ini:"repository.pull-request"` | } `ini:"repository.pull-request"` | ||||
// Issue Setting | // Issue Setting | ||||
DefaultMergeMessageMaxApprovers int | DefaultMergeMessageMaxApprovers int | ||||
DefaultMergeMessageOfficialApproversOnly bool | DefaultMergeMessageOfficialApproversOnly bool | ||||
PopulateSquashCommentWithCommitMessages bool | PopulateSquashCommentWithCommitMessages bool | ||||
AddCoCommitterTrailers bool | |||||
}{ | }{ | ||||
WorkInProgressPrefixes: []string{"WIP:", "[WIP]"}, | WorkInProgressPrefixes: []string{"WIP:", "[WIP]"}, | ||||
// Same as GitHub. See | // Same as GitHub. See | ||||
DefaultMergeMessageMaxApprovers: 10, | DefaultMergeMessageMaxApprovers: 10, | ||||
DefaultMergeMessageOfficialApproversOnly: true, | DefaultMergeMessageOfficialApproversOnly: true, | ||||
PopulateSquashCommentWithCommitMessages: false, | PopulateSquashCommentWithCommitMessages: false, | ||||
AddCoCommitterTrailers: true, | |||||
}, | }, | ||||
// Issue settings | // Issue settings |
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()) | 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()) | ||||
} | } | ||||
} else { | } else { | ||||
if committer != sig { | |||||
if setting.Repository.PullRequest.AddCoCommitterTrailers && committer.String() != sig.String() { | |||||
// add trailer | // add trailer | ||||
message += fmt.Sprintf("\nCo-authored-by: %s\nCo-committed-by: %s\n", sig.String(), sig.String()) | message += fmt.Sprintf("\nCo-authored-by: %s\nCo-committed-by: %s\n", sig.String(), sig.String()) | ||||
} | } |