Mercurial > lasercutter
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/graster/hacklab-engraver/.git/hooks/update.sample Tue Aug 24 19:06:45 2010 -0400 1.3 @@ -0,0 +1,128 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# An example hook script to blocks unannotated tags from entering. 1.7 +# Called by git-receive-pack with arguments: refname sha1-old sha1-new 1.8 +# 1.9 +# To enable this hook, rename this file to "update". 1.10 +# 1.11 +# Config 1.12 +# ------ 1.13 +# hooks.allowunannotated 1.14 +# This boolean sets whether unannotated tags will be allowed into the 1.15 +# repository. By default they won't be. 1.16 +# hooks.allowdeletetag 1.17 +# This boolean sets whether deleting tags will be allowed in the 1.18 +# repository. By default they won't be. 1.19 +# hooks.allowmodifytag 1.20 +# This boolean sets whether a tag may be modified after creation. By default 1.21 +# it won't be. 1.22 +# hooks.allowdeletebranch 1.23 +# This boolean sets whether deleting branches will be allowed in the 1.24 +# repository. By default they won't be. 1.25 +# hooks.denycreatebranch 1.26 +# This boolean sets whether remotely creating branches will be denied 1.27 +# in the repository. By default this is allowed. 1.28 +# 1.29 + 1.30 +# --- Command line 1.31 +refname="$1" 1.32 +oldrev="$2" 1.33 +newrev="$3" 1.34 + 1.35 +# --- Safety check 1.36 +if [ -z "$GIT_DIR" ]; then 1.37 + echo "Don't run this script from the command line." >&2 1.38 + echo " (if you want, you could supply GIT_DIR then run" >&2 1.39 + echo " $0 <ref> <oldrev> <newrev>)" >&2 1.40 + exit 1 1.41 +fi 1.42 + 1.43 +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then 1.44 + echo "Usage: $0 <ref> <oldrev> <newrev>" >&2 1.45 + exit 1 1.46 +fi 1.47 + 1.48 +# --- Config 1.49 +allowunannotated=$(git config --bool hooks.allowunannotated) 1.50 +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) 1.51 +denycreatebranch=$(git config --bool hooks.denycreatebranch) 1.52 +allowdeletetag=$(git config --bool hooks.allowdeletetag) 1.53 +allowmodifytag=$(git config --bool hooks.allowmodifytag) 1.54 + 1.55 +# check for no description 1.56 +projectdesc=$(sed -e '1q' "$GIT_DIR/description") 1.57 +case "$projectdesc" in 1.58 +"Unnamed repository"* | "") 1.59 + echo "*** Project description file hasn't been set" >&2 1.60 + exit 1 1.61 + ;; 1.62 +esac 1.63 + 1.64 +# --- Check types 1.65 +# if $newrev is 0000...0000, it's a commit to delete a ref. 1.66 +zero="0000000000000000000000000000000000000000" 1.67 +if [ "$newrev" = "$zero" ]; then 1.68 + newrev_type=delete 1.69 +else 1.70 + newrev_type=$(git-cat-file -t $newrev) 1.71 +fi 1.72 + 1.73 +case "$refname","$newrev_type" in 1.74 + refs/tags/*,commit) 1.75 + # un-annotated tag 1.76 + short_refname=${refname##refs/tags/} 1.77 + if [ "$allowunannotated" != "true" ]; then 1.78 + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 1.79 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 1.80 + exit 1 1.81 + fi 1.82 + ;; 1.83 + refs/tags/*,delete) 1.84 + # delete tag 1.85 + if [ "$allowdeletetag" != "true" ]; then 1.86 + echo "*** Deleting a tag is not allowed in this repository" >&2 1.87 + exit 1 1.88 + fi 1.89 + ;; 1.90 + refs/tags/*,tag) 1.91 + # annotated tag 1.92 + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 1.93 + then 1.94 + echo "*** Tag '$refname' already exists." >&2 1.95 + echo "*** Modifying a tag is not allowed in this repository." >&2 1.96 + exit 1 1.97 + fi 1.98 + ;; 1.99 + refs/heads/*,commit) 1.100 + # branch 1.101 + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then 1.102 + echo "*** Creating a branch is not allowed in this repository" >&2 1.103 + exit 1 1.104 + fi 1.105 + ;; 1.106 + refs/heads/*,delete) 1.107 + # delete branch 1.108 + if [ "$allowdeletebranch" != "true" ]; then 1.109 + echo "*** Deleting a branch is not allowed in this repository" >&2 1.110 + exit 1 1.111 + fi 1.112 + ;; 1.113 + refs/remotes/*,commit) 1.114 + # tracking branch 1.115 + ;; 1.116 + refs/remotes/*,delete) 1.117 + # delete tracking branch 1.118 + if [ "$allowdeletebranch" != "true" ]; then 1.119 + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 1.120 + exit 1 1.121 + fi 1.122 + ;; 1.123 + *) 1.124 + # Anything else (is there anything else?) 1.125 + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 1.126 + exit 1 1.127 + ;; 1.128 +esac 1.129 + 1.130 +# --- Finished 1.131 +exit 0