The comment referred to .github/README.md, which does not exist, and described the repo as having no remote with branch protection. The enforced rule now lives in .github/workflows/branch-policy.yml.
43 lines
1.4 KiB
Bash
Executable File
43 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Block direct commits to main — branch first, then open a PR. This and the
|
|
# pre-push guard are the local half of that rule, and a hook is only ever a
|
|
# courtesy: `--no-verify` skips it. The enforced half is
|
|
# .github/workflows/branch-policy.yml, which decides what may target main.
|
|
branch="$(git rev-parse --abbrev-ref HEAD)"
|
|
if [ "$branch" = "main" ]; then
|
|
echo "✖ Direct commits to 'main' are blocked — branch first: git switch -c <name>"
|
|
exit 1
|
|
fi
|
|
|
|
# The test suite deliberately does NOT run here. It runs in checks.yml on every
|
|
# PR, and locally via `make preflight` before you open one. A full `turbo run
|
|
# test` on every commit taxes exactly the fast checkpoint commits this repo
|
|
# lives on, and catches nothing that the PR gate would not.
|
|
|
|
# ultracite
|
|
# Check if there are any staged files
|
|
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR)
|
|
if [ -z "$STAGED_FILES" ]; then
|
|
echo "No staged files to format"
|
|
exit 0
|
|
fi
|
|
|
|
# Run formatter, capturing the exit code so we can still re-stage and report
|
|
FORMAT_EXIT_CODE=0
|
|
pnpm dlx ultracite fix || FORMAT_EXIT_CODE=$?
|
|
|
|
# Re-stage files that were already staged
|
|
echo "$STAGED_FILES" | while IFS= read -r file; do
|
|
if [ -f "$file" ]; then
|
|
git add -- "$file"
|
|
fi
|
|
done
|
|
|
|
if [ $FORMAT_EXIT_CODE -ne 0 ]; then
|
|
echo "Ultracite found issues that could not be auto-fixed."
|
|
exit $FORMAT_EXIT_CODE
|
|
fi
|
|
|
|
echo "✨ Files formatted by Ultracite"
|
|
# ultracite end
|