Skip to content

Instantly share code, notes, and snippets.

@c9s
Last active October 6, 2021 05:03
Show Gist options
  • Save c9s/1bc7e37ce689d0bcfd5ebdbfb0965a4d to your computer and use it in GitHub Desktop.
Save c9s/1bc7e37ce689d0bcfd5ebdbfb0965a4d to your computer and use it in GitHub Desktop.
git pre push blocker example
#!/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