[go: up one dir, main page]

Default.md MR template does not take precedence over Git commit message body on MR creation

Summary

GitLab 14.8 added support for default issue and MR templates. MR templates are stored in .gitlab/merge_request_templates/default,md and should be used when creating a new MR. The problem is with Git history in a branch, when the commit has a body e.g. closes #1 or any other multi-line git commit message. This text takes precedence in the description form, where the default template would be expected.

Additional scenario from #353548 (comment 852441327)

creating a MR from an issue or based on a branch which starts with an issue number.

This problem does not affect the project settings for merge request description templates, which take precedence over git commit messages (#353548 (comment 852823120)).

Steps to reproduce

  1. Add a MR template: dnsmichi_test/default-template@96b8777f
.gitlab/merge_request_templates/default.md

# Problem to solve

# Changelog entry

# Review tasks 
  1. Open the Web IDE and create a LICENSE file (or something else to commit).
  2. Create a new branch, and add closes #1 to the commit message with an empty line in between (or any other multi-line git commit message).
Add LICENSE

Closes #1 

or

Add License

git commit body line 1
git commit body line 2
git commit body line 3
git commit body line 4
git commit body line 5
  1. In the new MR view, the single commit message is split into title & body, not using the default template from .gitlab/merge_request_templates/default.md

Follow the same procedure to create a new branch, add several commits, and then add a new MR. Same behaviour.

Example Project

https://gitlab.com/dnsmichi_test/default-template

What is the current bug behavior?

The MR description keeps the single commit message. This may be unexpected if you have configured a default MR template.

What is the expected correct behavior?

There are two "right ways":

  • Throw away the git commit message and override with the default template (precedence win)
  • Keep the first git commit message for the MR title/body

I think this needs more discussion though, as changing the behavior with "git commit messages to MR descriptions" might break existing workflows.

This probably touches other settings how a MR title and description is generated from Git branch history.

Relevant logs and/or screenshots

Single Git Commit

image

image

Multiple Git Commits

image

image

image

image

image

dnsmichi_test/default-template!2

Multi-line Git commit message:

image

Output of checks

This bug happens on GitLab.com

Possible fixes

Evaluate whether a default MR template exists, and force its usage, not using the Git commit message body.

Related to #15846 (closed).

Edited by Michael Friedrich