Fail-safe commit sha scanning when `CI_COMMIT_BEFORE_SHA` is invalid
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?
-
Changelog entry added -
Documentation created/updated for GitLab EE, if necessary -
Documentation created/updated for this project, if necessary -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Job definition updated, if necessary -
Conforms to the code review guidelines -
Conforms to the Go guidelines -
Security reports checked/validated by reviewer
Edited by Zach Rice