Last active
October 6, 2021 05:03
-
-
Save c9s/1bc7e37ce689d0bcfd5ebdbfb0965a4d to your computer and use it in GitHub Desktop.
git pre push blocker example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# gist: https://gist.github.com/c9s/1bc7e37ce689d0bcfd5ebdbfb0965a4d | |
branch_blocked=local | |
remote_blocked=origin | |
remote="$1" | |
url="$2" | |
z40=0000000000000000000000000000000000000000 | |
while read local_ref local_sha remote_ref remote_sha | |
do | |
if [ "$local_sha" = $z40 ] | |
then | |
# Handle delete | |
: | |
else | |
echo "local ref: $local_ref" | |
echo "remote: $remote" | |
if [[ $local_ref =~ $branch_blocked && $remote == $remote_blocked ]] | |
then | |
echo "Branch '$local_ref' is blocked by yourself." >&2 | |
exit 1 | |
fi | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment