[go: up one dir, main page]

Skip to content

Squash/Merge commit template: split first_multiline_commit into 3 variables

In #348263 (comment 801839586) GitLab analyzed dogfooding Squash Commit Template feature and variable %{first_multiline_commit} added in !75819 (merged). It should be possible to add more information to commit, while retaining title, description and trailers of first multiline commit.

It's currently not possible, as there's no way of knowing what current commit message contains. It can have just the title, or title and description, or title, description and Git trailers.

A template like:

%{first_multiline_commit}

Squashed from: %{reference}

will break existing Git trailers.

On the other hand, template:

%{first_multiline_commit}
Squashed from: %{reference}

breaks convention when there's no multiline commit messages. There should be a blank line after first line.

Proposal

We could add new variables:

  • first_multiline_commit_title
  • first_multiline_commit_description
  • first_multiline_commit_trailers
  • first_commit_title
  • first_commit_description
  • first_commit_trailers

A template could then pick, choose and extend information more easily. Example of a template:

%{title}

%{first_multiline_commit_description}

See merge request %{reference}

%{first_multiline_commit_trailers}
MR: %{url}

Note that this template would still suffer from issue described in #349622 (closed), so the other one should be considered first.

Edited by Piotr Stankowski