script: pre push hook - ignore delete remote branch

This commit is contained in:
Andreas Stallinger
2016-03-14 17:02:27 +01:00
parent 1032b83a09
commit 0cc777a892
+29
View File
@@ -7,6 +7,9 @@ proteced_branches=("forced_tests" "master")
#proteced_branch='master'
current_branch=$(git symbolic-ref -q --short HEAD)
remote="$1"
url="$2"
FAIL="\033[31mFail:\033[00m"
PASS="\033[32mPass:\033[00m"
INFO="\033[33mInfo:\033[00m"
@@ -73,6 +76,32 @@ function run_tests {
cd $ROOTDIR
}
#handle delete remote branches
while read local_ref lorem_sha remote_ref remote_sha
do
if [ "$local_ref" == "(delete)" ]
then
if [ "$remote_ref" == "refs/heads/master" ]
then
echo "seriously dont delete the master"
exit 1
else
echo "delete remote branch $remote_ref"
exit 0
fi
fi
done
# handle push --tags
while read -d $'\0' arg ; do
if [[ "$arg" == '--tags' ]] ; then
echo "pushing tags"
exit 0
fi
done < /proc/$PPID/cmdline
for branch in "${proteced_branches[@]}"
do
if [ $current_branch == $branch ]