Implement merge and rebase for pipeline-less/merge train-less projects
As discussed in this spike, merge and rebase is a long-standing issue and can be implemented in a couple of ways:
From the spike, @hfyngvason mentions:
I would implement either
- fully within the
FromSourceBranch
merge strategy,- or, as a separate strategy, e.g.
RebaseFromSourceBranch
The operation would do the the following two steps:
- Prepare the candidate commit to replace the target branch HEAD into a temporary ref: First maybe squash, then maybe rebase, then maybe create a merge commit. This ensures the candidate commit is a fast-forward of the target branch. This can be done using
MergeRequests::CreateRefService
. The ref can be something likerefs/merge-requests/:iid/fast-forward
. Using just a single ref should be safe as long as we are explicit about the commit SHAs in each step instead of passing just the refs. We also already wrap merges with#in_locked_state
, which should prevent concurrent merges of a single MR.- Perform a fast-forward merge with this candidate commit into the target branch
This way, I think we get the cleanup for free (as long as we add the new ref to the list of refs to clean up after close/merge). I would not worry about contention for now:
- The fast-forward operation ensures safety by inherently working as an optimistic lock. The merge fails at the git level if the target branch has been updated in the meantime.
- Rebases are slower than standard merges, but still pretty fast. Projects with enough volume to run into contention due to the increased merge time can use merge trains with minimal pipelines.
I also think that making the mergeability check rebase-aware is more of a nice-to-have and should be done independently of the automatic rebase work.
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.