Add script to warn about pushing to master
This commit is contained in:
parent
8832a17f12
commit
85db1d5f02
1 changed files with 22 additions and 0 deletions
22
scripts/hooks/pre-push.protect-master.sh
Normal file
22
scripts/hooks/pre-push.protect-master.sh
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following snippet can be used to WARN about pushing to master
|
||||||
|
#
|
||||||
|
# Aborting the push is possible
|
||||||
|
#
|
||||||
|
|
||||||
|
protected_branch='master'
|
||||||
|
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
|
||||||
|
|
||||||
|
if [ $protected_branch = $current_branch ]; then
|
||||||
|
read -p "You're about to push master, is that what you intended? [y|n] " -n 1 -r < /dev/tty
|
||||||
|
echo
|
||||||
|
if echo $REPLY | grep -E '^[Yy]$' > /dev/null; then
|
||||||
|
exit 0 # push will execute
|
||||||
|
fi
|
||||||
|
exit 1 # push will not execute
|
||||||
|
else
|
||||||
|
exit 0 # push will execute
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue