Add check for existing MR with for same branch combo
What does this MR do and why?
Since we don't allow for multiple MRs with the same target and source
branch combination, add a check for any before we get to the MR
details creation page.This also will render the branch selection view when the user attempts to create an MR by accessing the creation page directly via url (/-/merge_requests/new?merge_request[source_branch]=my_new_branch
for example)
We do this by extracting the logic from MergeRequest#validate_branches
which is used in a validator, and run that check when attempting to render the "New merge request" edit/details page.
Screenshots or screen recordings
Existing MR
Note the flash message displayed when conflict is detected after pressing [Compare branches and continue]
. This messaging is identical to the existing validation error found on the MergeRequest
model.
How to set up and validate locally
- Create a merge request targeting the project's default branch (usually
master
ormain
) - Return to Branches page and attempt to create a new MR using the same source and target branch combination
- Attempt to go directly to "New merge request" edit page using URL
/-/merge_requests/new?merge_request[source_branch]=[whatever your source branch was named]
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #22015 (closed)