Preserve inferred issue reference for copied cherry-pick descriptions

What does this MR do and why?

Fixes a regression where copying a picked merge request description suppresses the inferred issue reference when Default.md contains %{closes_issue}.

The template-derived state normally prevents duplicating a reference rendered by the template. When a nonblank copied description replaces that rendered template, this MR clears only that stale state so the existing ordinary append behavior resumes.

It does not add content matching or generic deduplication, and does not change explicit-description precedence, authorization, visibility, queries, errors, placeholder substitution, or template behavior when no replacement occurs.

References

Closes #629938 (closed)

Screenshots or screen recordings

Before After
Not applicable; no UI change Not applicable; no UI change

How to set up and validate locally

  1. Add %{closes_issue} to .gitlab/merge_request_templates/Default.md.
  2. Create an issue.
  3. Cherry-pick a merged merge request with a nonblank description to a branch beginning with that issue's IID.
  4. Choose Create merge request and Copy merge request description.
  5. Confirm the copied description is preserved and followed by the inferred issue reference.
  6. Disable automatic issue closing and confirm the generated reference uses Related to.

Validation completed:

  • Focused regression spec — passed.
  • Complete MergeRequests::BuildService spec — passed.
  • Relevant MessageGenerator %{closes_issue} context — passed.
  • RuboCop for both changed files — passed.
  • git diff --check — passed.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

  • Changelog: included as Changelog: fixed.
  • Tests: focused regression coverage added and the complete affected service spec passes.
  • Documentation: no change required because this restores already documented behavior.
  • Screenshots: not applicable because there is no UI change.
  • Feature flag: skipped because this is a narrow deterministic backend regression fix without a migration, authorization change, or rollout risk.
  • Specialist review: ordinary backend maintainer review is sufficient; no AppSec, database, migration, UX, or product review is indicated.

AI assistance

AI tooling assisted with investigation and drafting. The contributor independently reviewed the implementation, reproduced the bug locally, verified the regression and fix, and takes responsibility for this change.

Edited by Whale Tech

Merge request reports

Loading
Loading