Skip to content

Commit

Permalink
feat: fail when running in a shallow git repository
Browse files Browse the repository at this point in the history
  • Loading branch information
jamacku committed Jan 9, 2025
1 parent 06c922a commit 4c4dd5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
if ! git diff --name-only -z --diff-filter=db "${BASE}".."${HEAD}" > "${WORK_DIR}changed-files.txt"; then
echo "::warning:: Please check if the repository was cloned with \`fetch-depth: 0\`. Differential ShellCheck needs the entire history to work correctly."
exit 1
fi

only_changed_scripts=()
get_scripts_for_scanning "${WORK_DIR}changed-files.txt" "only_changed_scripts"
Expand Down
3 changes: 1 addition & 2 deletions test/index.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ setup () {
load 'test_helper/bats-support/load'
}

# The purpose of this file is to get base for test coverage
@test "index.sh - source" {
SCRIPT_DIR=""
INPUT_TRIGGERING_EVENT="manual"
INPUT_BASE="base"
INPUT_HEAD="head"
run . "$PROJECT_ROOT/src/index.sh"

assert_success
}

teardown () {
Expand Down

0 comments on commit 4c4dd5f

Please sign in to comment.