Skip to content

Add a new `reviewed_by` variable for commit messages

What does this MR do and why?

Two commits:

  1. Reviews are currently stored in the reviews database table, and a merge request has a reviews association. This commit adds a new has_many :reviewed_by_users, -> { distinct }, through: :reviews, source: :author to streamline the gathering of historical unique reviewers of a merge request.
  2. The Merge commit template now supports the %{reviewed_by} placeholder. For each reviewers of a merge request (i.e. people that submitted a review), the Merge commit message will include a Reviewed-by: Git trailer.

Screenshots or screen recordings

Placeholder usage in the Merge commit template Screen_Shot_2022-10-18_at_23.41.55
Effective replacement of the placeholder in the "Edit commit message" textarea of the MR widget Screen_Shot_2022-10-18_at_23.44.27
Effective replacement of the placeholder in the merge commit Screen_Shot_2022-10-18_at_23.46.00

How to set up and validate locally

  1. Add %{reviewed_by} to the Merge commit template of a project
  2. Open a merge request from this project
  3. Perform two separate reviews with the same user and one with another user
  4. Merge the merge request
  5. Open the merge commit and check that it has two Reviewed-by: trailers (one for the first reviewer, one for the second one)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #378352 (closed)

Edited by Nick Veenhof

Merge request reports