Skip to content

Commit 9a0f771

Browse files
authored
Add main branch protection scripts (#3133)
## Description I saw software-mansion/react-native-reanimated#6555 and I remembered a great advice from @kacperkapusciak: > Kradnij and so I did ## Test plan Try to commit something on `main`
1 parent f52f6f5 commit 9a0f771

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

.husky/pre-commit

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4+
print() {
5+
echo " [PRECOMMIT]: $1" >&2
6+
}
7+
8+
BRANCH=$(git symbolic-ref HEAD)
9+
if [ "$BRANCH" = "refs/heads/main" ]; then
10+
print "You tried to commit to main, which is probably a mistake. Aborting commit."
11+
exit 1
12+
fi
13+
414
yarn lint-staged
515
yarn ts-check

.husky/pre-push

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env sh
2+
3+
print() {
4+
echo " [PREPUSH]: $1" >&2
5+
}
6+
7+
BRANCH=$(git symbolic-ref HEAD)
8+
if [ "$BRANCH" = "refs/heads/main" ]; then
9+
print "You tried to push to main, which is probably a mistake. Aborting push."
10+
exit 1
11+
fi

0 commit comments

Comments
 (0)