CI: Fix [check_commit_message.sh] in merged result pipelines
What
Fixes #7436 (closed).
Why
As noted by @onurb, the issue is that check_commit_messages.sh
relies on the CI_MERGE_REQUEST_{SOURCE,TARGET}_BRANCH_SHA
variables that are only available in merged result pipelines.
We use merged result pipelines, but if the source MR cannot be rebased without conflict, then its pipelines revert to merge request pipelines, making the above variables empty. More info on the issue can be found in #7436 (closed).
How
In non-merged result pipelines, take the merge base of HEAD and
${ORIGIN}/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} instead. This
requires fetching the latter to make sure that git_merge_base.sh
does not fail.
Manually testing the MR
I ran this pipeline once as a merged result pipeline:
and once as a merge request pipeline:
(note the extra commit I added in this case to provoke a conflict such that the pipeline would revert to a merge request pipeline).
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR