Skip to content

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

  1. Check out this branch

  2. In a rails console, run

    Feature.enable(:merge_trains_create_ref_service)
  3. In a project, enable merge trains and allow squash merges

  4. For each available merge method, perform the following actions:

    1. Change to that merge method
    2. Create a merge request in this project
    3. Start a merge train. Arbitrarily decide whether to squash or not. Just don't do the same thing each time.
    4. Check the pipelines page. There should be a merge train for your merge request. Click the commit ref for this merge request.
    5. Verify that the commit message is what you expected.
    6. Change the /commit/ portion of the URL to /commits/ (plural) to browse the commit history
    7. 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.

Edited by Hordur Freyr Yngvason

Merge request reports