fix(scripts): row 211 R3 push guard tags, installer hooks dir, busy check errors (#1709)

This commit is contained in:
jason.woltje committed 2026-11-02 13:50:11 -06:00
1 parent 3a121885cf
commit 7d03f212db
9 files changed
+378 -25

No files matched your search

+16 -2
View File
@@ -7,8 +7,10 @@
#
# DIR defaults to this script's own checkout. The hook's bytes are this
# checkout's scripts/git-hooks/pre-push. It refuses when core.hooksPath is set
# (git would not run the hook), and when a different pre-push is installed,
# unless --force-install is given. It never edits an installed hook in place:
# (git would not run the hook), when the hooks directory is a symlink or
# resolves anywhere but the common directory's hooks, and when a different
# pre-push is installed, unless --force-install is given. It never edits an
# installed hook in place:
# a new hook is linked in, a replacement is renamed over the old one. A canary
# then runs the installed hook through git and needs a delete refused.
#
@@ -55,8 +57,20 @@ HOOK="$HOOKS/pre-push"
out=$(g config --show-scope --get-all core.hooksPath 2>/dev/null)
[ -z "$out" ] || die 2 "refused: core.hooksPath is set ($(printf '%s' "$out" | tr '\n\t' '; ')), so git would not run the push guard; unset it first"
# The hooks directory must be the common directory's own. Through a symlink
# to a shared directory, the install would set the hook of every repository
# that shares it. Checked before and after mkdir, before any file is written.
own_hooks() {
local real want
[ ! -L "$HOOKS" ] || die 2 "refused: $HOOKS is a symlink; install only into the repository's own hooks directory"
[ -e "$HOOKS" ] || return 0
real=$(cd -P -- "$HOOKS" && pwd -P) && want="$(cd -P -- "$common" && pwd -P)/hooks" || die 1 "cannot resolve $HOOKS"
[ "$real" = "$want" ] || die 2 "refused: $HOOKS resolves to $real, not $want"
}
own_hooks
if [ -L "$HOOK" ]; then die 2 "refused: $HOOK is a symlink; remove it by hand if it is not wanted"; fi
mkdir -p "$HOOKS" || die 1 "cannot create $HOOKS"
own_hooks
tmp="$HOOKS/.pre-push.install-git-hooks.$$"
if [ -e "$HOOK" ]; then
[ -f "$HOOK" ] || die 2 "refused: $HOOK is not a regular file"