Files
worldmonitor/.husky/pre-commit
Elie Habib 90a626dd26 fix(husky): guard against commits/pushes to merged or closed PR branches (#1979)
Pre-commit now checks gh pr state before allowing any commit — exits 1
with a clear message if the branch PR is MERGED or CLOSED, preventing
orphaned commits (as happened on PRs #1893, #1898, and #1974).

Pre-push: changed 2>/dev/null to 2>&1 so gh errors surface visibly,
and added a state echo line so the current PR state is always logged.
2026-03-21 12:25:19 +04:00

17 lines
767 B
Plaintext
Executable File

BRANCH=$(git branch --show-current)
if [ -n "$BRANCH" ] && [ "$BRANCH" != "main" ] && [ "$BRANCH" != "master" ]; then
PR_STATE=$(gh pr view "$BRANCH" --json state --jq '.state' 2>/dev/null)
if [ "$PR_STATE" = "MERGED" ] || [ "$PR_STATE" = "CLOSED" ]; then
echo ""
echo "============================================================"
echo "ERROR: PR for branch '$BRANCH' is $PR_STATE."
echo "Do NOT commit to a merged/closed PR branch — commits will be orphaned."
echo "Run: git checkout main && git pull && git checkout -b fix/new-branch"
echo "============================================================"
exit 1
fi
fi
echo "Running Unicode safety check (staged files)..."
node scripts/check-unicode-safety.mjs --staged || exit 1