24 lines
791 B
Shell
24 lines
791 B
Shell
|
|
#!/usr/bin/env sh
|
||
|
|
set -eu
|
||
|
|
|
||
|
|
product_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||
|
|
git_root=$(git -C "$product_root" rev-parse --show-toplevel 2>/dev/null || true)
|
||
|
|
|
||
|
|
if [ -z "$git_root" ]; then
|
||
|
|
echo "GHNQG_FAIL_0 gate=automatic_protocol_bindings reason=git_root_missing" >&2
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
product_prefix=$(git -C "$product_root" rev-parse --show-prefix)
|
||
|
|
hooks_path="${product_prefix}.husky"
|
||
|
|
|
||
|
|
git -C "$git_root" config --local core.hooksPath "$hooks_path"
|
||
|
|
chmod +x "$product_root/.husky/pre-commit" "$product_root/.husky/pre-push"
|
||
|
|
|
||
|
|
configured=$(git -C "$git_root" config --local --get core.hooksPath)
|
||
|
|
if [ "$configured" != "$hooks_path" ]; then
|
||
|
|
echo "GHNQG_FAIL_0 gate=automatic_protocol_bindings reason=hooks_path_mismatch" >&2
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "GHNQG_HOOKS_ACTIVE path=$hooks_path"
|