Unify response from UI and API for rebase operation
What does this MR do and why?
Contributes #386537 (closed)
Problem
- The rebase validation logic is duplicated in two places
- Rebase action in controller returns a html 404 page, instead of a json response with an error.
Solution
- Move shared logic into MergeRequests::RebaseService.
- Change the rebase response in controller to return json error.
Screenshots or screen recordings
Rebase button on the merge request page
![](/-/project/278964/uploads/b641d57a9f3dc99d99aa848bfe98323e/Screenshot_2022-12-27_at_11.54.46.png)
Before fix | After fix |
---|---|
![]() |
![]() |
How to set up and validate locally
- Go to Project Settings -> Merge requests and set Fast-forward merge option.
- Create a merge request that is behind of the default branch
- Make merge request source branch protected with force push restriction
- Press Rebase button on the merge request page
- See an error
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.
Edited by Vasilii Iakliushin