Mercurial > lasercutter
view graster/hacklab-engraver/.git/hooks/update.sample @ 11:f952052e37b7
trying a fix.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 24 Aug 2010 19:06:45 -0400 |
parents | |
children |
line wrap: on
line source
1 #!/bin/sh2 #3 # An example hook script to blocks unannotated tags from entering.4 # Called by git-receive-pack with arguments: refname sha1-old sha1-new5 #6 # To enable this hook, rename this file to "update".7 #8 # Config9 # ------10 # hooks.allowunannotated11 # This boolean sets whether unannotated tags will be allowed into the12 # repository. By default they won't be.13 # hooks.allowdeletetag14 # This boolean sets whether deleting tags will be allowed in the15 # repository. By default they won't be.16 # hooks.allowmodifytag17 # This boolean sets whether a tag may be modified after creation. By default18 # it won't be.19 # hooks.allowdeletebranch20 # This boolean sets whether deleting branches will be allowed in the21 # repository. By default they won't be.22 # hooks.denycreatebranch23 # This boolean sets whether remotely creating branches will be denied24 # in the repository. By default this is allowed.25 #27 # --- Command line28 refname="$1"29 oldrev="$2"30 newrev="$3"32 # --- Safety check33 if [ -z "$GIT_DIR" ]; then34 echo "Don't run this script from the command line." >&235 echo " (if you want, you could supply GIT_DIR then run" >&236 echo " $0 <ref> <oldrev> <newrev>)" >&237 exit 138 fi40 if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then41 echo "Usage: $0 <ref> <oldrev> <newrev>" >&242 exit 143 fi45 # --- Config46 allowunannotated=$(git config --bool hooks.allowunannotated)47 allowdeletebranch=$(git config --bool hooks.allowdeletebranch)48 denycreatebranch=$(git config --bool hooks.denycreatebranch)49 allowdeletetag=$(git config --bool hooks.allowdeletetag)50 allowmodifytag=$(git config --bool hooks.allowmodifytag)52 # check for no description53 projectdesc=$(sed -e '1q' "$GIT_DIR/description")54 case "$projectdesc" in55 "Unnamed repository"* | "")56 echo "*** Project description file hasn't been set" >&257 exit 158 ;;59 esac61 # --- Check types62 # if $newrev is 0000...0000, it's a commit to delete a ref.63 zero="0000000000000000000000000000000000000000"64 if [ "$newrev" = "$zero" ]; then65 newrev_type=delete66 else67 newrev_type=$(git-cat-file -t $newrev)68 fi70 case "$refname","$newrev_type" in71 refs/tags/*,commit)72 # un-annotated tag73 short_refname=${refname##refs/tags/}74 if [ "$allowunannotated" != "true" ]; then75 echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&276 echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&277 exit 178 fi79 ;;80 refs/tags/*,delete)81 # delete tag82 if [ "$allowdeletetag" != "true" ]; then83 echo "*** Deleting a tag is not allowed in this repository" >&284 exit 185 fi86 ;;87 refs/tags/*,tag)88 # annotated tag89 if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&190 then91 echo "*** Tag '$refname' already exists." >&292 echo "*** Modifying a tag is not allowed in this repository." >&293 exit 194 fi95 ;;96 refs/heads/*,commit)97 # branch98 if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then99 echo "*** Creating a branch is not allowed in this repository" >&2100 exit 1101 fi102 ;;103 refs/heads/*,delete)104 # delete branch105 if [ "$allowdeletebranch" != "true" ]; then106 echo "*** Deleting a branch is not allowed in this repository" >&2107 exit 1108 fi109 ;;110 refs/remotes/*,commit)111 # tracking branch112 ;;113 refs/remotes/*,delete)114 # delete tracking branch115 if [ "$allowdeletebranch" != "true" ]; then116 echo "*** Deleting a tracking branch is not allowed in this repository" >&2117 exit 1118 fi119 ;;120 *)121 # Anything else (is there anything else?)122 echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2123 exit 1124 ;;125 esac127 # --- Finished128 exit 0