Skip to content

Fail-safe commit sha scanning when `CI_COMMIT_BEFORE_SHA` is invalid

Zach Rice requested to merge failsafe-commitsha into master

What does this MR do?

This MR will default to scanning just one commit if git log returns an error when trying to determine a range of commits. This happens occasionally when CI_COMMIT_BEFORE_SHA yields an invalid, or squashed commit that (I think) is still cached by the pipeline.

Ex, I just opened a MR (the HEAD commit of the MR will kick off a pipeline when pushed, setting CI_COMMIT_BEFORE_SHA for subsequent pipelines) and noticed that I should squash a few commits into one. CI_COMMIT_BEFORE_SHA was one of the commits that got squashed. So when I push a new commit to the branch, the git log command using CI_COMMIT_BEFORE_SHA will be invalid.

The changes proposed here provide a fail safe way to give scan even when CI_COMMIT_BEFORE_SHA is invalid.

What are the relevant issue numbers?

Does this MR meet the acceptance criteria?

Edited by Zach Rice

Merge request reports