diff --git a/hooks/dstr.sh b/hooks/dstr.sh new file mode 100644 index 0000000..bbc4c95 --- /dev/null +++ b/hooks/dstr.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Configuration - where to fetch the full script from +SCRIPT_REPO="https://git.kjan.de/jank/scripts.git" +SCRIPT_PATH="hooks/pre-recieve.sh" +BRANCH="main" + +# Temporary directory +TEMP_DIR=$(mktemp -d) +trap 'rm -rf "$TEMP_DIR"' EXIT + +# Clone only the needed branch and specific file for efficiency +git clone --depth 1 --branch "$BRANCH" --single-branch "$SCRIPT_REPO" "$TEMP_DIR" >/dev/null 2>&1 + +if [ ! -f "$TEMP_DIR/$SCRIPT_PATH" ]; then + echo "Error: Could not fetch validation script from repository" + exit 1 +fi + +# Make the script executable +chmod +x "$TEMP_DIR/$SCRIPT_PATH" + +# Pass all input to the downloaded script and preserve its exit code +cat | "$TEMP_DIR/$SCRIPT_PATH" +exit $?