docs: suggest setting fetch-depth on ref errors (#5316)

Emit a hopefully more helpful error message when the Git ref doesn't
exist. The error message is the same we use when getting changed files
only: it suggests checking that repository clone is not shallow, and
that the full history is available. Additionally, when running on
GitHub Actions, it also suggests checking the fetch-depth option of the
actions/checkout step.

Fix #5315
This commit is contained in:
Marco Ferrari 2024-02-27 13:25:18 +01:00 committed by GitHub
parent 52b082b1f6
commit 608bd502d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View file

@ -8,6 +8,7 @@ function IssueHintForFullGitHistory() {
info "See https://github.com/super-linter/super-linter#get-started"
info "Is shallow repository: $(git -C "${GITHUB_WORKSPACE}" rev-parse --is-shallow-repository)"
}
export -f IssueHintForFullGitHistory
function GenerateFileDiff() {
local DIFF_GIT_DEFAULT_BRANCH_CMD

View file

@ -200,6 +200,7 @@ function ValidateGitShaReference() {
debug "Validate that the GITHUB_SHA reference (${GITHUB_SHA}) exists in this Git repository."
if ! CheckIfGitRefExists "${GITHUB_SHA}"; then
IssueHintForFullGitHistory
fatal "The GITHUB_SHA reference (${GITHUB_SHA}) doesn't exist in this Git repository"
else
debug "The GITHUB_SHA reference (${GITHUB_SHA}) exists in this repository"