From ef76367358dd7e34501a509031cc30f6aaddd368 Mon Sep 17 00:00:00 2001 From: Bert Roos Date: Tue, 23 May 2023 02:30:16 +0200 Subject: [PATCH] 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 --- lib/functions/buildFileList.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index 579197c4..867183be 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -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