From 61e0a47cab28c2cf559926260880838b5eda54c0 Mon Sep 17 00:00:00 2001 From: Viktor Adam Date: Mon, 7 Oct 2024 10:55:36 +1000 Subject: [PATCH] Fix existing test issues :blue_heart: --- base-template.sh | 8 +++++--- tests/step-061.sh | 4 ++-- tests/test-opensuse.sh | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/base-template.sh b/base-template.sh index b3e9622f..ae5412ec 100755 --- a/base-template.sh +++ b/base-template.sh @@ -98,6 +98,10 @@ set_main_variables() { ACCEPT_CHANGES= CURRENT_GIT_DIR=$(git rev-parse --git-common-dir 2>/dev/null) + if [ -z "${CURRENT_GIT_DIR}" ] && [ -n "${GIT_DIR}" ]; then + # Patch up the current git dir when the above did not find it yet, perhaps during git init + CURRENT_GIT_DIR="${GIT_DIR}" + fi if [ ! -d "${CURRENT_GIT_DIR}" ]; then echo "! Hook not run inside a git repository" >&2 return 1 @@ -405,12 +409,10 @@ is_trusted_repo() { fi fi fi - + return 1 } - - ##################################################### # Performs checks for new and changed hooks, # and prompts the user for approval if needed. diff --git a/tests/step-061.sh b/tests/step-061.sh index d6db7281..8b1ee684 100644 --- a/tests/step-061.sh +++ b/tests/step-061.sh @@ -15,9 +15,9 @@ mkdir -p /tmp/shared/first-shared.git/.githooks/pre-commit && git config --global githooks.shared 'file:///tmp/shared/first-shared.git' || exit 1 mkdir -p /tmp/test061/.githooks && - echo '/tmp/shared/second-shared.git' >/tmp/test061/.githooks/.shared && cd /tmp/test061 && - git init || + git init && + echo '/tmp/shared/second-shared.git' >/tmp/test061/.githooks/.shared || exit 1 if git hooks list | grep -q "sample-one"; then diff --git a/tests/test-opensuse.sh b/tests/test-opensuse.sh index 58e63fd9..dc572888 100755 --- a/tests/test-opensuse.sh +++ b/tests/test-opensuse.sh @@ -4,7 +4,7 @@ TEST_DIR=$(dirname "$0") cat <