Fix merge commit result in MergeRequests::CreateRefService
What does this MR do and why?
Fix merge commit result in MergeRequests::CreateRefService
A bug slipped in during the last round of reviews when introducing the
service. The ref was created correctly, but the incorrect result was
returned due to assigning the result of the merge to source_sha
instead of commit_sha
. This caused the merge train pipeline to use the
wrong commit SHA.
This bug is hidden behind a feature flag, and was detected during testing on staging. No users are affected.
A test gap is what allowed the bug to slip past. We were not testing the
return values of MergeRequests::CreateRefService#execute
. Additional
checks have been added to the spec that would have caught this bug, and
similar ones for other merge methods.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
-
Check out this branch
-
In a rails console, run
Feature.enable(:merge_trains_create_ref_service)
-
In a project, enable merge trains and allow squash merges
-
For each available merge method, perform the following actions:
- Change to that merge method
- Create a merge request in this project
- Start a merge train. Arbitrarily decide whether to squash or not. Just don't do the same thing each time.
- Check the pipelines page. There should be a merge train for your merge request. Click the commit ref for this merge request.
- Verify that the commit message is what you expected.
- Change the
/commit/
portion of the URL to/commits/
(plural) to browse the commit history - Verify that the commit history is as expected for the given merge method.
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.