From bade6ddb945cecb794bb61e408e65a1e9517a435 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Thu, 9 Jan 2025 13:48:47 +0100 Subject: [PATCH] feat: fail when running in a shallow git repository --- src/index.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.sh b/src/index.sh index 3b66dd51..4c3b729f 100755 --- a/src/index.sh +++ b/src/index.sh @@ -41,7 +41,10 @@ if ! [[ ${FULL_SCAN} -eq 0 ]] || ! is_strict_check_on_push_demanded; then # https://github.com/actions/runner/issues/342 # Get the names of files from range of commits (excluding deleted files) # BASE and HEAD are always set, it is checked inside pick_base_and_head_hash function - git diff --name-only -z --diff-filter=db "${BASE}".."${HEAD}" > "${WORK_DIR}changed-files.txt" + set -e + git diff --name-only -z --diff-filter=db "${BASE}".."${HEAD}" > "${WORK_DIR}changed-files.txt" || \ + echo "::warning:: Please check if repository was cloned with \`fetch-depth: 0\`. Differential ShellCheck needs full history to work properly." + set +e only_changed_scripts=() get_scripts_for_scanning "${WORK_DIR}changed-files.txt" "only_changed_scripts"