mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
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.
17 lines
767 B
Plaintext
Executable File
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
|