Add co_authored_by to merge commit templates
What does this MR do and why?
This merge requests add support for %{co_authored_by}
variable in a merge commit templates. This solves #20421 (closed).
Variable expands to list of commit authors in a form:
Co-authored-by: Zane Doe <zdoe@example.com>
Co-authored-by: Alex Garcia <agarcia@example.com>
This format is often used by various tools to add more authors to a single commit, and would be most useful in a squash commit template. The format is already somewhat supported by gitlab, as the user mentioned that way is linked to in a commit view (see screenshots section).
A lot of complexity was added by the fact that the main commit author shouldn't be mentioned as a co-author. For merge commit, that means we should skip merging user (for non-merged MR we assume currently logged in user), while for squash commit we should skip MR author. We could simplify things a bit and future-proof this if we decided to ignore that and always include commit author as a co-author as well, so let me know if you'd rather have the simpler, but a bit less user-friendly version.
Screenshots or screen recordings
Docs:
The format is already somewhat supported by gitlab, as the user mentioned that way is linked to (it would just be a mailto link if no account would be tied to given email address):
How to set up and validate locally
- Go to any project -> settings -> general.
- Expand Merge Requests section.
- Fill in
Merge commit message template
orSquash commit message template
with new variable%{co_authored_by}
. - Commit a new branch with couple commits created by different authors (with different emails).
- Create a new MR from this branch.
- Check that the default message in MR widget renders co authors correctly.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.