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"
|
||||
|
|
@ -10,6 +10,7 @@ active_authority_surfaces=(
|
|||
".github/workflows/ci.yml"
|
||||
".github/workflows/README.md"
|
||||
".husky/pre-push"
|
||||
"scripts/install-guanghu-native-hooks.sh"
|
||||
"scripts/run-hololake-native-quality-gate.sh"
|
||||
".claude/settings.local.json"
|
||||
".chunk/config.json"
|
||||
|
|
@ -47,6 +48,10 @@ if grep -Ein \
|
|||
fi
|
||||
|
||||
grep -Fq 'GLS-0844' "${repository_root}/AGENTS.md"
|
||||
grep -Fq 'install-guanghu-native-hooks.sh' "${repository_root}/package.json"
|
||||
grep -Fq 'core.hooksPath' "${repository_root}/scripts/install-guanghu-native-hooks.sh"
|
||||
grep -Fq 'cd "$hook_dir/.."' "${repository_root}/.husky/pre-commit"
|
||||
grep -Fq 'cd "$hook_dir/.."' "${repository_root}/.husky/pre-push"
|
||||
grep -Fq 'GHNQG_PASS_100' "${repository_root}/.husky/pre-push"
|
||||
grep -Fq 'run-hololake-native-quality-gate.sh' "${repository_root}/.husky/pre-push"
|
||||
grep -Fq 'run-hololake-native-quality-gate.sh' "${repository_root}/.github/workflows/ci.yml"
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ for (const required of [
|
|||
}
|
||||
|
||||
const packageJson = JSON.parse(source('package.json'))
|
||||
requireTruth(packageJson.scripts.prepare.includes('install-guanghu-native-hooks.sh'), 'trigger_hook_install')
|
||||
requireTruth(packageJson.scripts.predev === 'pnpm test:native-authority', 'trigger_predev')
|
||||
requireTruth(packageJson.scripts.pretest === 'pnpm test:native-authority', 'trigger_pretest')
|
||||
requireTruth(
|
||||
|
|
@ -56,11 +57,14 @@ requireTruth(
|
|||
'trigger_prebuild',
|
||||
)
|
||||
requireTruth(source('.husky/pre-commit').includes('test-guanghu-native-authority.sh'), 'trigger_precommit')
|
||||
requireTruth(source('.husky/pre-commit').includes('cd "$hook_dir/.."'), 'trigger_precommit_product_root')
|
||||
requireTruth(
|
||||
source('.husky/pre-push').includes('test:native-authority')
|
||||
|| source('.husky/pre-push').includes('run-hololake-native-quality-gate.sh'),
|
||||
'trigger_prepush',
|
||||
)
|
||||
requireTruth(source('.husky/pre-push').includes('cd "$hook_dir/.."'), 'trigger_prepush_product_root')
|
||||
requireTruth(source('scripts/install-guanghu-native-hooks.sh').includes('core.hooksPath'), 'trigger_hooks_path')
|
||||
requireTruth(source('.github/workflows/ci.yml').includes('test:native-authority'), 'trigger_ci')
|
||||
requireTruth(
|
||||
source('.github/workflows/ci.yml').includes('run-hololake-native-quality-gate.sh'),
|
||||
|
|
|
|||
Loading…
Reference in a new issue