Skip to content
Snippets Groups Projects

Add co_authored_by to merge commit templates

Merged Piotr Stankowski requested to merge trakos/gitlab:merge_template_add_co_authors into master
All threads resolved!

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:

image

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):

image

How to set up and validate locally

  1. Go to any project -> settings -> general.
  2. Expand Merge Requests section.
  3. Fill in Merge commit message template or Squash commit message template with new variable %{co_authored_by}.
  4. Commit a new branch with couple commits created by different authors (with different emails).
  5. Create a new MR from this branch.
  6. 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.

Edited by Piotr Stankowski

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • @trakos thanks for this great contribution! :slight_smile: I left a comment in !75639 (comment 760671957) that is also applicable to this MR.

    FYI regarding the dependency of this MR with !75639 (merged), I marked that other MR as blocking this one:

    image

  • Pedro Moreira da Silva removed review request for @pedroms

    removed review request for @pedroms

  • Piotr Stankowski added 2749 commits

    added 2749 commits

    Compare with previous version

  • Piotr Stankowski changed the description

    changed the description

  • Piotr Stankowski
  • Piotr Stankowski
  • Piotr Stankowski
  • Piotr Stankowski changed title from Draft: Add co_authors to merge commit templates to Draft: Add co_authored_by to merge commit templates

    changed title from Draft: Add co_authors to merge commit templates to Draft: Add co_authored_by to merge commit templates

  • Pedro Moreira da Silva approved this merge request

    approved this merge request

  • Piotr Stankowski marked this merge request as ready

    marked this merge request as ready

  • Piotr Stankowski marked the checklist item I have evaluated the MR acceptance checklist for this MR. as completed

    marked the checklist item I have evaluated the MR acceptance checklist for this MR. as completed

  • Amy Qualls requested review from @aqualls

    requested review from @aqualls

    • Resolved by Amy Qualls

      question (non-blocking): is it time to stop listing all the options?

      As we keep adding more substitution options, should we stop listing them below the text area, and instead link out to the docs, like we do for markdown and quick actions?

  • Amy Qualls changed milestone to %14.7

    changed milestone to %14.7

  • Amy Qualls requested review from @alexbuijs and removed review request for @aqualls

    requested review from @alexbuijs and removed review request for @aqualls

  • added 1 commit

    • 738e778b - Add co_authored_by to merge commit templates

    Compare with previous version

  • added 1 commit

    • 143e577c - Add co_authored_by to merge commit templates

    Compare with previous version

  • Piotr Stankowski changed the description

    changed the description

  • Piotr Stankowski
  • mentioned in issue #349193 (closed)

  • Alex Buijs
  • Alex Buijs approved this merge request

    approved this merge request

  • Alex Buijs requested review from @dbalexandre and removed review request for @alexbuijs

    requested review from @dbalexandre and removed review request for @alexbuijs

  • Piotr Stankowski mentioned in merge request !77350 (merged)

    mentioned in merge request !77350 (merged)

  • resolved all threads

  • Douglas Barbosa Alexandre approved this merge request

    approved this merge request

  • Douglas Barbosa Alexandre enabled an automatic merge when the pipeline for 8a1cfb7b succeeds

    enabled an automatic merge when the pipeline for 8a1cfb7b succeeds

  • @trakos Thanks for your contribution :tada: This LGTM. I triggered a new pipeline and set MWPS.

  • A deleted user added backend label

    added backend label

  • Hi @trakos,

    We would love to know how you found your code review experience in this merge request! Please leave a :thumbsup: or a :thumbsdown: on this comment to describe your experience.

    Once done, please comment @gitlab-bot feedback below and feel free to leave any additional feedback you have in the same comment.

    Thanks for your help! :heart:

  • mentioned in commit 316fbdcb

  • added workflowcanary label and removed workflowstaging label

  • added workflowproduction label and removed workflowcanary label

  • Piotr Stankowski mentioned in merge request !77758 (merged)

    mentioned in merge request !77758 (merged)

  • Please register or sign in to reply
    Loading