Find the right commit SHA
Find the right commit SHA.
We only allow fast-forward merges and no merge commits. This means that the source branch SHA should become the tip of the target branch when the mrege request is merged.
However, GitLab CI supports different pipeline types, each with varying predefined variables.
CI_MERGE_REQUEST_SOURCE_BRANCH_SHA exists in "merged results" pipelines,
but it's empty in "merge request" pipelines.
CI_COMMIT_SHA exists in both but its value differs.
In "merged results" pipelines, the value is the SHA of the merge commit.
In "merge request" pipelines, the value matches the source branch SHA.
Oddly enough, GitLab CI sometimes triggers the "merge request" pipeline even when a fast-forward merge is possible. Which means that we need to be able to handle both types of pipelines, and work with the correct SHA.
ROG_COMMIT_SHA variable contains the right commit SHA, regardless
of the pipeline type.
Related: OSCI-8068