Create merge refs for MRs (merge and squash methods)
We provide refs/merge-requests/$iid/head
for checking out the HEAD of a merge request. We could also provide a corresponding refs/merge-requests/$iid/merge
for the merge result of the merge.
We already calculate this when someone loads an unchecked merge request to see if there are conflicts. Instead of throwing that away, we could write the result to the ref. This would allow CI services to checkout and test the result of the merge request rather than the just the HEAD
of the feature branch which may not be accurate.
Proposal
- when the merge result is calculated write the result to
refs/merge-requests/$iid/merge
- add API method to manually trigger calculation of the merge ref
Challenges: the merge ref will only be valid for the HEAD of the target branch when the merge commit is generated. If the HEAD of the target branch changes the merge ref will not be automatically updated.
Ideally, we would use this ref for merging, but we'd need to make sure that we can atomically update the ref (if needed) and then merge. This is out of scope
Work
- gitaly!1057 (merged)
- https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24692
- https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9471
- https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24918