Imagine this scenario:
- I create a merge request where I modified a file in
src/. This triggers a long-running test job in the CI/CD pipeline. - I forgot to update the readme, so I push another commit. I don't want to run the long-running test again, since the readme is not in
src/.
My idea now is to check the files that have changed between pipeline 1 and 2. We've enabled merged results pipelines (so GitLab creates a commit with the result of the source and target branches merged together when running pipelines).
My merge request has these pipelines:
| Pipeline ID | Pipeline Type | Commit SHA | Notes |
|---|---|---|---|
| #1 | merged results | fca36db3 | First push with changes to src/ |
| #2 | merged results | 6cb35df4 | Second push with changes to the readme |
My CI/CD job looks like this:
job:
script:
- git diff fca36db3..6cb35df4 --
The output:
$ git diff fca36db3..6cb35df4 --
fatal: bad revision 'fca36db3..6cb35df4'
Obviously the merge commits created by GitLab aren't available here. I've tried to set GIT_STRATEGY to clone and GIT_DEPTH to 0, without success. Is it even possible to work with these commits?
It's possible to get these commits from another repository by creating a branch off of them. Idea from Can I view the reflog of a remote (not remote ref)?