Replace MergeToRefService with CreateRefService for merged results pipelines and mergability check - Backend
Release notes
Previously, the HEAD commit would get copied over to a Merge train ref in squash and rebase projects. When the git command git checkout "$CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"
is used for auto-rebased forked pipelines it would return a failure because the source commit history is rewritten, meaning a new commit SHA is created for the target repository instead of the $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
. In 17.0, we will be improving the mergability check and merge request pipelines to support a seamless commit history while using semi-linear or fast-foward merges with merge trains.
Problem to solve
MergeRequests::MergeToRefService
is used for mergability checks and for the merged result pipeline creation (and the mergeability check), but it can only merge via a merge commit. This means that for projects with semi-linear or fast-forward merges configured, it does not represent the merged result.
Proposal
Add a project setting that is defaulted to off so it inherits the defined project merge method.
For example, in the settings it would say:
Enable merged result pipelines
- Use project merge method: The merged result is squashed and rebased according to the project and merge request preferences. Otherwise, only a merge commit is created, and no squash is performed.
Implementation details
- Use
MergeRequests::CreateRefService
when creating the merge request refrefs/merge-requests/:iid/merge
. - The change should be feature flagged with a project actor
- Since rebases are more expensive than merges, and the mergeability check gets a lot of traffic, consider adding a limit on the number of commits allowed before a manual rebase is required. The limit can be either static or configurable.
- This can be a follow-up, but the feature flag should not be removed before some sound limit is in place.
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.