Skip to content

MR widget: update merge commit message when default changed

What does this MR do and why?

Solves #348338.

When project uses merge commit template with %{approved_by} variable, approving a MR currently does not update commit message. That means that maintainer that approves and merges currently is not included in commit message, unless he refreshes the page after approval but before merging.

Additionally, even for default commit template, if commit title was updated in the background, it is not reflected in a merge commit message.

This MR aims to fix that. As long as user did not modify default commit message, message will be automatically updated after approval. However, if the user edited the commit message manually, further updates will be ignored. It's best explained by the recording in a section below.

Technically, it is achieved by checking for default message change on every graphql reload in ReadyToMerge vue widget. Approval already triggered graphql reload. Whenever graphql data is reloaded in ReadyToMerge widget and change in default commit message is detected (both for merge and for squash) and user has not customized the message yet, it is automatically updated.

The graphql data reload is behind :merge_request_widget_graphql feature flag, so it's required for this change as well. However, it's on by default and from what I understand, it's planned for removal: #267560 (closed).

Screenshots or screen recordings

Since recording this I've reverted one change: clicking merge no longer updates MR state before. The title that I've changed in the other tab would not be used, the commit would still have the old MR title.

2021-12-29_23-48__Display__OC_Studio_

How to set up and validate locally

  1. Go to project settings -> general -> merge request section.
  2. Fill in "Merge commit message template" and "Squash commit message template", use %{approved_by} variable.
  3. Create a MR.
  4. Click "Modify merge commit".
  5. Click "Approve", make sure that merge commit message is automatically updated.
  6. Modify merge commit message, make sure that clicking "Unapprove" no longer automatically updates merge commit message.

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