Strip draft prefix before evaluating required title pattern in mergeability check

What does this MR do and why?

When a project has a required MR title pattern configured, marking an MR as a draft (which prepends Draft: or WIP: to the title) caused the title pattern merge check to fail -- even when the underlying title without the draft prefix satisfied the regex. Draft status is already surfaced by its own dedicated merge check, so the title pattern check should not produce a spurious failure.

Fix: Strip any draft prefix from the MR title using the existing MergeRequest.draftless_title helper before evaluating it against the required title pattern regex in CheckMergeRequestTitleRegexService#valid_project_regex. This is consistent with the approach taken in !249733 (merged).

Spec changes: Added three new examples to the existing spec:

  • Draft: prefix + matching underlying title -> success
  • WIP: prefix + matching underlying title -> success
  • Draft: prefix + non-matching underlying title -> failure (regression guard)

References

Screenshots or screen recordings

N/A -- backend-only change.

How to set up and validate locally

  1. Create a project and enable the merge_request_title_regex_check licensed feature.
  2. Set a required title regex, e.g. PROJ-\d+.
  3. Create an MR with title PROJ-123 -- the title check should pass.
  4. Mark the MR as draft (title becomes Draft: PROJ-123) -- the title check should still pass (previously it would fail).
  5. Create an MR with title Draft: unrelated -- the title check should fail.

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.

Merge request reports

Loading
Loading