From 85edfa71280cbf184321d6ebea65aac1529e3d21 Mon Sep 17 00:00:00 2001 From: mnovak Date: Sat, 7 Nov 2026 19:22:32 +0100 Subject: [PATCH] [repo] Hook self-test: keep its source files next to the work dir by absolute path and remove them first, so a run leaves nothing behind --- .githooks/test-pre-commit.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.githooks/test-pre-commit.sh b/.githooks/test-pre-commit.sh index a7a239c..771e14a 100755 --- a/.githooks/test-pre-commit.sh +++ b/.githooks/test-pre-commit.sh @@ -65,8 +65,11 @@ expect_staged() { B='-----BEGIN' E='-----END' -mkdir -p "$WORK/../ianitor-hook-src.$$" && SRC="$WORK/../ianitor-hook-src.$$" -trap 'rm -rf "$WORK" "$SRC"' EXIT INT TERM +# An absolute path next to $WORK (not "$WORK/..", which no longer resolves once $WORK is gone), +# removed first. +SRC="$(dirname "$WORK")/ianitor-hook-src.$$" +mkdir -p "$SRC" || exit 2 +trap 'rm -rf "$SRC" "$WORK"' EXIT INT TERM printf '%s RSA PRIVATE KEY-----\nMIIBOgIBAAJBAK\n%s RSA PRIVATE KEY-----\n' "$B" "$E" > "$SRC/pem" head -c 6291456 /dev/zero | tr '\000' 'a' > "$SRC/six-mb"