From 38a37d1bd4e4df18543444d166bc6ee866ab0f95 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 5 Nov 2022 11:28:50 +0100 Subject: [PATCH] Use hash to check git binary --- entrypoint.sh | 10 +++++++--- tests/git-auto-commit.bats | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 9d9f9bf..5661a91 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -45,9 +45,13 @@ _main() { } _check_if_git_is_available() { - PATH_TO_GIT=$(which $INPUT_INTERNAL_GIT_BINARY); - - echo "::debug::Path to git binary ${PATH_TO_GIT}"; + if hash -- "$INPUT_INTERNAL_GIT_BINARY" 2> /dev/null; then + echo "git found"; + echo "::debug::git binary found"; + else + echo "git not found. git-auto-commit requires git to be available." >&2 + exit 1 + fi } _switch_to_repository() { diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index f85f653..bbec849 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -1051,4 +1051,5 @@ cat_github_output() { run git_auto_commit assert_failure; + assert_line "git not found. git-auto-commit requires git to be available." }