Update git hooks to protect main branch and force good practices

This commit is contained in:
Pablo Baleztena 2024-09-18 22:46:53 -03:00
parent 3713812956
commit e96a8aa85c
2 changed files with 20 additions and 1 deletions

View File

@ -1,2 +1,9 @@
# .husky/pre-commit
yarn lint-staged
yarn lint-staged
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "main" ]; then
echo "You can't commit directly to main branch"
exit 1
fi

12
.husky/pre-push Normal file
View File

@ -0,0 +1,12 @@
# .husky/pre-push
branch="$(git rev-parse --abbrev-ref HEAD)"
while read local_ref local_sha remote_ref remote_sha
do
echo $local_ref
echo $local_sha
echo $remote_ref
echo $remote_sha
done
exit 1