Fix issue with merge_pipeline when using ff merges
What does this MR do?
Issue: #212691 (closed)
When a project uses the Fast-Forward Merge strategy for MRs then there is an issue with MergeRequest#merge_pipeline
where the value of merge_commit_sha
will be nil
because, of course, there was no merge commit. This results in fetching the entire history of pipelines up to HEAD
as that is the default behavior of Project#pipeline_for
.
This MR instead chooses diff_head_sha
when merge_commit_sha
is nil
.
Issue Repro
- Create a new project.
- Add a
.gitlab-ci.yml
file:stages: - test test: stage: test script: - echo "hello world"
- In
Settings > General > Merge requests > Merge method
chooseFast-forward merge
- Make a change (like in some README.md file or whatever) and create a MR from the change.
- Once the pipeline succeeds, merge the MR.
- Make another change, and another MR, and then merge that MR as well.
- Go back to the first MR and verify that the most recently listed pipeline and commit are the correct ones, and not just links to the more recent MR/pipeline.
Screenshots
Before:
After:
How it should work:
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines - [-] Merge request performance guidelines
-
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
- [-] Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Amy Troschinetz