Issue hint when failing to switch back to branch (#4107)

* Issue hint when failing to switch back to branch

Switching back to the branch fails with the below error on a shallow checkout:

2023-04-18 21:34:51 [ERROR]   Failed to switch back to branch!
2023-04-18 21:34:51 [FATAL]   [fatal: reference is not a tree: 3afa21b5f9bef8e81396e3572a598d089e710b96]

With this change, it will look as follows:

2023-04-18 21:34:51 [ERROR]   Failed to switch back to branch!
2023-04-18 21:34:51 [INFO]   Check that you have the full git history, the checkout is not shallow, etc
2023-04-18 21:34:51 [INFO]  See https://github.com/github/super-linter#example-connecting-github-action-workflow
2023-04-18 21:34:51 [FATAL]   [fatal: reference is not a tree: 3afa21b5f9bef8e81396e3572a598d089e710b96]

* Update lib/functions/buildFileList.sh

---------

Co-authored-by: Philip Mallegol-Hansen <philip@mallegolhansen.com>
This commit is contained in:
Bert Roos 2023-05-23 02:30:16 +02:00 committed by GitHub
parent 92f290dba4
commit ef76367358
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,14 @@
################################################################################
########################## FUNCTION CALLS BELOW ################################
################################################################################
################################################################################
#### Function BuildFileList ####################################################
function IssueHintForFullGitHistory() {
info "Check that you have the full git history, the checkout is not shallow, etc"
info "See https://github.com/github/super-linter#example-connecting-github-action-workflow"
}
################################################################################
#### Function GenerateFileDiff #################################################
function GenerateFileDiff() {
@ -33,8 +41,7 @@ function GenerateFileDiff() {
if [ ${ERROR_CODE} -ne 0 ]; then
# Error
info "Failed to get Diff with:[$CMD]"
info "Check that you have the full git history, the checkout is not shallow, etc"
info "See https://github.com/github/super-linter#example-connecting-github-action-workflow"
IssueHintForFullGitHistory
fatal "[${CMD_OUTPUT}]"
fi
@ -224,6 +231,7 @@ function BuildFileList() {
if [ ${ERROR_CODE} -ne 0 ]; then
# Error
error "Failed to switch back to branch!"
IssueHintForFullGitHistory
fatal "[${SWITCH2_CMD}]"
fi
fi