|
root / hooks / test / cases / 04-hg-command-allows.sh
04-hg-command-allows.sh Bash 21 lines 465 B
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
# Case 04: 'hg status' inside an .hg repo must be allowed (only git is blocked).
set -u

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT

mkdir -p "$tmp/repo/.hg"

input=$(jq -n --arg cwd "$tmp/repo" --arg cmd "hg status" '{
  cwd: $cwd,
  hook_event_name: "PreToolUse",
  tool_name: "Bash",
  tool_input: { command: $cmd }
}')

if ! echo "$input" | "$HOOK_SCRIPT" >/dev/null 2>&1; then
    echo "expected exit 0 (allow), got non-zero"
    exit 1
fi