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 -> successWIP:prefix + matching underlying title -> successDraft:prefix + non-matching underlying title -> failure (regression guard)
References
- Closes #624452
- Related: !249733 (merged)
Screenshots or screen recordings
N/A -- backend-only change.
How to set up and validate locally
- Create a project and enable the
merge_request_title_regex_checklicensed feature. - Set a required title regex, e.g.
PROJ-\d+. - Create an MR with title
PROJ-123-- the title check should pass. - Mark the MR as draft (title becomes
Draft: PROJ-123) -- the title check should still pass (previously it would fail). - 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.