mirror of
https://github.com/purhan/dotfiles.git
synced 2025-12-26 14:24:58 +08:00
add git hooks
This commit is contained in:
parent
360f6f1127
commit
491262ff58
2 changed files with 21 additions and 0 deletions
17
src/scripts/hooks/git/pre-push
Executable file
17
src/scripts/hooks/git/pre-push
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
|
||||
protected_branches="main master dev"
|
||||
|
||||
if [[ "$protected_branches" == *"$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…
Add table
Add a link
Reference in a new issue