Rebase and merge with one click
Problem
When using merge commit with semi-linear history and fast-forward merge methods, if the target branch has changed since the source branch was created or last rebased, the source branch will need to be rebased before merging in order to merge according to the selected merge method.
Currently, if GitLab detects a rebase is required, the users can click the Rebase button. Once the rebase is completed the Merge button will become available. This require more time as I have to return to MR to check when rebase is done and then merge.
Proposal
Now that FF-merge trains exists I think much of the implementation could also be re-used as follows (no Gitaly changes required):
- Use
MergeRequests::CreateRefService
to create a merge candidate ref, for examplerefs/merge-requests/:iid/rebase-merge
- Perform a fast-forward merge from
refs/merge-requests/:iid/rebase-merge
into the target branch. If the target branch has been updated in the meantime, this would gracefully fail (in which case we could retry or display an error to the user).
Further details
- The importance of this feature is magnified by both the requirement for CI pipelines to pass before merging.
- There is appetite to merge immediately after the rebase is successful without running CI. While some feel this should not be the default, those folks would like to have the option to make that desicion.
- This will not solve contention between many merge requests with slow pipelines. See &4911 (closed) for
Merge Trains with Fast Forward Merge support
Old proposal
- For the two merge request methods (
merge commit with semi-linear history
andfast-forward merge
), offer the ability to rebase and merge in a single action. - Note: For below,
strikethroughindicates existing functionality that will be removed and bold indicates new functionality.
- No pipeline exists (No GitLab CI set up)
- MR needs a rebase
- MR is non-rebaseable
Merge button, and an error after clicking the button- Access to source branch: Rebase locally button that shows instructions (button; instructions modal) If rebase succeeds, show message “Ready to be merged automatically. Ask someone with write access to this repository to merge this request.”
- No access to source branch: No buttons, only message to ask MR author to rebase locally (message)
- MR is rebaseable
- Access to only source branch: Rebase button (rebase) If rebase succeeds, show message “Ready to be merged automatically. Ask someone with write access to this repository to merge this request.”
- Access to source AND target branch: Merge and Rebase only buttons. Merge will auto-rebase+merge immediately. (merge or rebase only) If Rebase only, after it succeeds, show Merge button.
- No access to source branch: No buttons, only message to ask MR author to rebase (message)
- MR is non-rebaseable
- MR does not need a rebase
- Merge button
- Pipeline running
- MR needs a rebase
- MR is non-rebaseable
Merge button, and an error after clicking the button- Access to source branch: Rebase locally button that shows instructions (button; instructions modal) If rebase succeeds, show message “Ready to be merged automatically. Ask someone with write access to this repository to merge this request.”
- No access to source branch: No buttons, only message to ask MR author to rebase locally (message)
- MR is rebaseable
- Access to only source branch: Rebase button (rebase) If rebase succeeds, show message “Ready to be merged automatically. Ask someone with write access to this repository to merge this request.”
- Access to source AND target branch: Merge (blue button) and Rebase only buttons. Merge will auto-rebase+merge immediately. (merge or rebase only) If Rebase only, after it succeeds, show Merge (blue) and Merge when pipeline succeeds (orange) buttons.
- No access to source branch: No buttons, only message to ask MR author to rebase (message)
- Not in scope: Merge when pipeline succeeds button (blue) that will auto-rebase+merge when pipeline succeeds
- MR is non-rebaseable
- MR does not need a rebase
- Merge when pipeline succeeds button (blue)
- Merge button (orange) to merge immediately
- Pipeline passed
- Same as 1. No pipeline exists, above
- Pipeline failed
- Pending discussion
Customers
- https://gitlab.my.salesforce.com/00161000002xBfL
- https://gitlab.my.salesforce.com/0014M00001nHkqA
- https://gitlab.my.salesforce.com/00161000004zrG3
- https://gitlab.my.salesforce.com/00161000004yLEy
- https://gitlab.my.salesforce.com/0016100000fdr2y
- https://gitlab.my.salesforce.com/00161000005cxCt
- https://gitlab.my.salesforce.com/00161000002xBao
Links / references
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.