Show merge source in the merge request widget

What does this MR do and why?

When a merge request is marked as merged because another merge request or a direct push included its changes, the widget says "Approval is optional" and only "Merged by", so it looks like it skipped approval. Behind the merge_request_widget_merge_source feature flag (wip, default off), the widget now says how it was merged and that it was not approved in this merge request.

Third of three MRs for #512551. Stacked on !260938 (merged), which adds the mergeSource GraphQL field this reads. The final wording needs UX and technical writing review.

Screenshots

Case Before (flag off) After (flag on)
Merged through another merge request 1-merged-through-mr-flag-off 3-merged-through-mr-flag-on
Merged by a direct push 2-direct-push-flag-off 4-direct-push-flag-on
Merged in GitLab (unchanged) 5-merged-in-gitlab-flag-on
Details
  • mr_widget_merged.vue adds a second line under "Merged by": "Merged through !N" (linked), "Merged by a direct push of sha", or "Merged through another merge request" when the viewer can't read the source.
  • approvals_summary.vue replaces "Approval is optional" with "Not approved in this merge request. Its changes were merged through !N." (or "by a direct push."). Real partial approvals still show as before; it only replaces the optional text, and it does not copy the other merge request's approvals.
  • Both components run one small query, merge_source.query.graphql, with Apollo skip when the flag is off (the approvals wrapper also skips unless the merge request is merged). The flag-off widget never requests mergeSource, so this can merge before the field is deployed everywhere. The field is marked @gl_introduced(version: "19.6.0").
  • Reproduced in GDK with real merges. The "merged through" screenshots were taken with !260499 applied locally; without it, the race in #456426 can record a commit source for these merge requests, and the widget then shows the direct-push text.
  • Tests: Jest for the merged widget (flag off skips the query, merged in GitLab, through a merge request, by a push, unreadable source), the approvals wrapper (flag off, not merged, merged), and the summary messages. CE and EE approvals specs pass (147 tests). No changelog entry because the flag is default off.

How to set up and validate locally

  1. Enable the flag: Feature.enable(:merge_request_widget_merge_source).
  2. Create merge request A, then merge request B from a branch that contains A's commits. Merge B.
  3. Open A: the merged state shows "Merged through !B" and the approvals summary says it was not approved in this merge request.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Kai Armstrong

Merge request reports

Loading
Loading