Skip to content

Add first_commit and first_multiline_commit to commit template

What does this MR do and why?

This MR adds first_commit and first_multiline_commit to merge/squash commit message templates.

Solves #346805 (closed).

The linked issue only asked for first_multiline_commit, but reading through the previous discussions, some users were disliking the arbitrary way it works - it uses first non-merge commit with more than one line in message body. You can have a couple commits with well-defined but single-line messages, then a revert, and revert would be used, as it tends to have more than one line. Also, first_multiline_commit becomes MR title when no multiline commit exists in MR. This was brought up in comment #330646 (comment 572918071).

For these reasons, I've decided to also add first_commit variable.

Screenshots or screen recordings

Added new variables to documentation, also added version history to this section and fixed %{description} example:

image

Example of using this new variables. New variables are also listed below textareas:

image

Example of message templates from previous screenshot in use - rendered messages:

image

How to set up and validate locally

  1. Go to project settings.
  2. Fill in Merge commit message template or Squash commit message template with one of new variables (%{first_commit}, %{first_multiline_commit}).
  3. Create a new MR.
  4. Check that the default message in mr widget renders 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