@miller-tech/uap 1.147.3 → 1.147.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
Binary file
|
|
@@ -16,7 +16,40 @@ HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
16
16
|
# from inside a worktree the gate found no policies.db and silently skipped ALL
|
|
17
17
|
# policy enforcement. Anchor DB + enforcer paths to MAIN_ROOT to fix that, while
|
|
18
18
|
# keeping the enforcer working directory on the actual working tree.
|
|
19
|
-
|
|
19
|
+
# Resolve the working tree the operation TARGETS, not just the hook's own cwd.
|
|
20
|
+
# For a Bash op the command usually `cd`s into a worktree before running git, but
|
|
21
|
+
# this hook fires BEFORE that cd — so using the hook's cwd yielded the MAIN
|
|
22
|
+
# checkout and made git-diff enforcers (expert-review, local-build) reason about
|
|
23
|
+
# the wrong branch on compound `cd worktree && git ...` commands. Prefer, in
|
|
24
|
+
# order: a leading `cd <path>` in the command, the payload's invocation cwd, then
|
|
25
|
+
# git-toplevel from the hook's cwd.
|
|
26
|
+
_CD_TARGET="$(UAP_PAYLOAD="$PAYLOAD" python3 - <<'PYEOF'
|
|
27
|
+
import json, os, re
|
|
28
|
+
try:
|
|
29
|
+
d = json.loads(os.environ.get("UAP_PAYLOAD") or "{}")
|
|
30
|
+
ti = d.get("tool_input") or d.get("args") or {}
|
|
31
|
+
cmd = ti.get("command") or ""
|
|
32
|
+
m = re.match(r'\s*cd\s+(?:"([^"]+)"|\x27([^\x27]+)\x27|([^\s;&|]+))', cmd)
|
|
33
|
+
print((m.group(1) or m.group(2) or m.group(3)) if m else "")
|
|
34
|
+
except Exception:
|
|
35
|
+
print("")
|
|
36
|
+
PYEOF
|
|
37
|
+
)"
|
|
38
|
+
_PAYLOAD_CWD="$(UAP_PAYLOAD="$PAYLOAD" python3 - <<'PYEOF'
|
|
39
|
+
import json, os
|
|
40
|
+
try:
|
|
41
|
+
print(json.loads(os.environ.get("UAP_PAYLOAD") or "{}").get("cwd") or "")
|
|
42
|
+
except Exception:
|
|
43
|
+
print("")
|
|
44
|
+
PYEOF
|
|
45
|
+
)"
|
|
46
|
+
CHECKOUT_ROOT=""
|
|
47
|
+
for _cand in "$_CD_TARGET" "$_PAYLOAD_CWD"; do
|
|
48
|
+
[[ -z "$_cand" || ! -d "$_cand" ]] && continue
|
|
49
|
+
_top="$(git -C "$_cand" rev-parse --show-toplevel 2>/dev/null || true)"
|
|
50
|
+
[[ -n "$_top" ]] && { CHECKOUT_ROOT="$_top"; break; }
|
|
51
|
+
done
|
|
52
|
+
[[ -z "$CHECKOUT_ROOT" ]] && CHECKOUT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
|
|
20
53
|
[[ -z "$CHECKOUT_ROOT" ]] && CHECKOUT_ROOT="$(cd "$HOOK_DIR/../.." 2>/dev/null && pwd || pwd)"
|
|
21
54
|
MAIN_ROOT="${CHECKOUT_ROOT%%/.worktrees/*}"
|
|
22
55
|
|