Skip to content

Commit 7507f1b

Browse files
authored
add pre-push hook to guard against accidental pushes directly to canary (#66030)
We allow users in the Next.js team to push directly canary in order to allow emergency fixes (and, AFAIU, some other things in GH workflows). This PR adds a guardrail to prevent absentminded people from doing it by accident, requiring a 'git push --no-verify' to bypass the hook.
1 parent 4c70239 commit 7507f1b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.husky/pre-push

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
main_branch="canary"
4+
5+
branch="$(git rev-parse --abbrev-ref HEAD)"
6+
7+
if [ "$branch" = "$main_branch" ]; then
8+
echo "You probably didn't intend to push directly to '$main_branch'." >&2
9+
echo "If you're sure that that's what you want to do, bypass this check via" >&2
10+
echo "" >&2
11+
echo " git push --no-verify" >&2
12+
echo "" >&2
13+
exit 1
14+
fi

0 commit comments

Comments
 (0)