Skip to content

Fix issue with merge_pipeline when using ff merges

Amy Troschinetz requested to merge fix-pipeline-link into master

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

  1. Create a new project.
  2. Add a .gitlab-ci.yml file:
    stages:
      - test
    
    test:
      stage: test
      script:
        - echo "hello world"
  3. In Settings > General > Merge requests > Merge method choose Fast-forward merge ff
  4. Make a change (like in some README.md file or whatever) and create a MR from the change.
  5. Once the pipeline succeeds, merge the MR.
  6. Make another change, and another MR, and then merge that MR as well.
  7. 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:

before

After:

after

How it should work:

Screen_Shot_2020-08-20_at_9.32.58_AM

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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

Merge request reports