Last active
January 11, 2016 16:52
-
-
Save dmitrythaler/234f8b2446391e52f361 to your computer and use it in GitHub Desktop.
pre-receive gist hook, shared repository
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 | |
# this pre-receive hook returns error when you are trying to push your silly code to the PRODUCTION branch not being member of repo administrators group | |
REPOADMINGROUP='repo-admin' | |
GROUPS_=`groups` | |
PRODUCTIONBRANCH='master' | |
while read oldsha newsha REFNAME; do | |
# GROUPS_ line doesn't contain REPOADMINGROUP and REFNAME contains PRODUCTIONBRANCH | |
if [[ $GROUPS_ != *$REPOADMINGROUP* ]] && [[ $REFNAME == *PRODUCTIONBRANCH* ]]; then | |
echo pre-receive check ERROR: refname: $REFNAME - you are NOT ALLOWED to push to this branch | |
exit 255 | |
else | |
echo pre-receive check OK | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, where did you place this hooks in GitHUb?