fix: activate native protocol hooks in nested worktrees
This commit is contained in:
parent
67e6fcdd38
commit
97858eb8b5
7 changed files with 48 additions and 4 deletions
24
product-source/hololake-platform/scripts/install-guanghu-native-hooks.sh
Executable file
24
product-source/hololake-platform/scripts/install-guanghu-native-hooks.sh
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/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"
|
||||
Loading…
Reference in a new issue