X-Git-Url: http://xvm.mit.edu/gitweb/invirt/scripts/git-hooks.git/blobdiff_plain/49288335f73df1dfc830f99a7f568715fafcb8c8..0a9cf90391cf2ced2cf02b93c193e31ab0733569:/sub/update diff --git a/sub/update b/sub/update index 11adb92..2986daa 100755 --- a/sub/update +++ b/sub/update @@ -13,16 +13,37 @@ if [ -z "$GIT_DIR" ]; then exit 1 fi -if [ -z "$ref" -o -z "$oldrev" -o -z "$newrev" ]; then +if [ -z "$ref" ] || [ -z "$oldrev" ] || [ -z "$newrev" ]; then echo "Usage: $0 " >&2 exit 1 fi +# --- Disallow pushing to the branches for pockets + +pocket_to_git() { + local pocket git + pocket="$1" + git="$(invirt-getconf "git.pockets.$pocket.git" 2>/dev/null)" + if [ $? != 0 ]; then + git="$pocket" + fi + echo "$git" +} + +for pocket in $(invirt-getconf -l git.pockets); do + if [ "$ref" = "refs/heads/$(pocket_to_git "$pocket")" ]; then + echo "*** Pushing to a pocket branch in this repository is not allowed" >&2 + exit 1 + fi +done + # --- Disallow pushing tags case "$ref" in - refs/tags/*) - echo "*** Pushing tags to this repository is not allowed" >&2 + refs/heads/*) + ;; + *) + echo "*** Pushing non-branches to this repository is not allowed" >&2 exit 1 ;; esac