-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathno-squash.sh
More file actions
executable file
·28 lines (24 loc) · 899 Bytes
/
Copy pathno-squash.sh
File metadata and controls
executable file
·28 lines (24 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
set -euo pipefail
# tested with: claude code v2.1.122
# =============================================================================
# No Squash: PreToolUse command blocker
# =============================================================================
# Blocks any squash merge attempt. regular merges only, preserve commit history.
#
# Hook type: PreToolUse (matcher: "Bash")
#
# Exit codes:
# 0 = allow the command to proceed
# 2 = block the command
# =============================================================================
INPUT=$(cat)
COMMAND=$(printf '%s' "$INPUT" | jq -r '.tool_input.command // ""')
if [ -z "$COMMAND" ]; then
exit 0
fi
if printf '%s' "$COMMAND" | grep -qiE '(git\s+merge|gh\s+pr\s+merge).*--squash'; then
echo "BLOCKED by no-squash: squash merges are not allowed. use regular merge to preserve commit history." >&2
exit 2
fi
exit 0