Fork of my MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:45:51 2017 +0000
Revision:
0:f1d3878b8dd9
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vpcola 0:f1d3878b8dd9 1 #!/bin/sh
vpcola 0:f1d3878b8dd9 2 #
vpcola 0:f1d3878b8dd9 3 # An example hook script to blocks unannotated tags from entering.
vpcola 0:f1d3878b8dd9 4 # Called by "git receive-pack" with arguments: refname sha1-old sha1-new
vpcola 0:f1d3878b8dd9 5 #
vpcola 0:f1d3878b8dd9 6 # To enable this hook, rename this file to "update".
vpcola 0:f1d3878b8dd9 7 #
vpcola 0:f1d3878b8dd9 8 # Config
vpcola 0:f1d3878b8dd9 9 # ------
vpcola 0:f1d3878b8dd9 10 # hooks.allowunannotated
vpcola 0:f1d3878b8dd9 11 # This boolean sets whether unannotated tags will be allowed into the
vpcola 0:f1d3878b8dd9 12 # repository. By default they won't be.
vpcola 0:f1d3878b8dd9 13 # hooks.allowdeletetag
vpcola 0:f1d3878b8dd9 14 # This boolean sets whether deleting tags will be allowed in the
vpcola 0:f1d3878b8dd9 15 # repository. By default they won't be.
vpcola 0:f1d3878b8dd9 16 # hooks.allowmodifytag
vpcola 0:f1d3878b8dd9 17 # This boolean sets whether a tag may be modified after creation. By default
vpcola 0:f1d3878b8dd9 18 # it won't be.
vpcola 0:f1d3878b8dd9 19 # hooks.allowdeletebranch
vpcola 0:f1d3878b8dd9 20 # This boolean sets whether deleting branches will be allowed in the
vpcola 0:f1d3878b8dd9 21 # repository. By default they won't be.
vpcola 0:f1d3878b8dd9 22 # hooks.denycreatebranch
vpcola 0:f1d3878b8dd9 23 # This boolean sets whether remotely creating branches will be denied
vpcola 0:f1d3878b8dd9 24 # in the repository. By default this is allowed.
vpcola 0:f1d3878b8dd9 25 #
vpcola 0:f1d3878b8dd9 26
vpcola 0:f1d3878b8dd9 27 # --- Command line
vpcola 0:f1d3878b8dd9 28 refname="$1"
vpcola 0:f1d3878b8dd9 29 oldrev="$2"
vpcola 0:f1d3878b8dd9 30 newrev="$3"
vpcola 0:f1d3878b8dd9 31
vpcola 0:f1d3878b8dd9 32 # --- Safety check
vpcola 0:f1d3878b8dd9 33 if [ -z "$GIT_DIR" ]; then
vpcola 0:f1d3878b8dd9 34 echo "Don't run this script from the command line." >&2
vpcola 0:f1d3878b8dd9 35 echo " (if you want, you could supply GIT_DIR then run" >&2
vpcola 0:f1d3878b8dd9 36 echo " $0 <ref> <oldrev> <newrev>)" >&2
vpcola 0:f1d3878b8dd9 37 exit 1
vpcola 0:f1d3878b8dd9 38 fi
vpcola 0:f1d3878b8dd9 39
vpcola 0:f1d3878b8dd9 40 if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
vpcola 0:f1d3878b8dd9 41 echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
vpcola 0:f1d3878b8dd9 42 exit 1
vpcola 0:f1d3878b8dd9 43 fi
vpcola 0:f1d3878b8dd9 44
vpcola 0:f1d3878b8dd9 45 # --- Config
vpcola 0:f1d3878b8dd9 46 allowunannotated=$(git config --bool hooks.allowunannotated)
vpcola 0:f1d3878b8dd9 47 allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
vpcola 0:f1d3878b8dd9 48 denycreatebranch=$(git config --bool hooks.denycreatebranch)
vpcola 0:f1d3878b8dd9 49 allowdeletetag=$(git config --bool hooks.allowdeletetag)
vpcola 0:f1d3878b8dd9 50 allowmodifytag=$(git config --bool hooks.allowmodifytag)
vpcola 0:f1d3878b8dd9 51
vpcola 0:f1d3878b8dd9 52 # check for no description
vpcola 0:f1d3878b8dd9 53 projectdesc=$(sed -e '1q' "$GIT_DIR/description")
vpcola 0:f1d3878b8dd9 54 case "$projectdesc" in
vpcola 0:f1d3878b8dd9 55 "Unnamed repository"* | "")
vpcola 0:f1d3878b8dd9 56 echo "*** Project description file hasn't been set" >&2
vpcola 0:f1d3878b8dd9 57 exit 1
vpcola 0:f1d3878b8dd9 58 ;;
vpcola 0:f1d3878b8dd9 59 esac
vpcola 0:f1d3878b8dd9 60
vpcola 0:f1d3878b8dd9 61 # --- Check types
vpcola 0:f1d3878b8dd9 62 # if $newrev is 0000...0000, it's a commit to delete a ref.
vpcola 0:f1d3878b8dd9 63 zero="0000000000000000000000000000000000000000"
vpcola 0:f1d3878b8dd9 64 if [ "$newrev" = "$zero" ]; then
vpcola 0:f1d3878b8dd9 65 newrev_type=delete
vpcola 0:f1d3878b8dd9 66 else
vpcola 0:f1d3878b8dd9 67 newrev_type=$(git cat-file -t $newrev)
vpcola 0:f1d3878b8dd9 68 fi
vpcola 0:f1d3878b8dd9 69
vpcola 0:f1d3878b8dd9 70 case "$refname","$newrev_type" in
vpcola 0:f1d3878b8dd9 71 refs/tags/*,commit)
vpcola 0:f1d3878b8dd9 72 # un-annotated tag
vpcola 0:f1d3878b8dd9 73 short_refname=${refname##refs/tags/}
vpcola 0:f1d3878b8dd9 74 if [ "$allowunannotated" != "true" ]; then
vpcola 0:f1d3878b8dd9 75 echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
vpcola 0:f1d3878b8dd9 76 echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
vpcola 0:f1d3878b8dd9 77 exit 1
vpcola 0:f1d3878b8dd9 78 fi
vpcola 0:f1d3878b8dd9 79 ;;
vpcola 0:f1d3878b8dd9 80 refs/tags/*,delete)
vpcola 0:f1d3878b8dd9 81 # delete tag
vpcola 0:f1d3878b8dd9 82 if [ "$allowdeletetag" != "true" ]; then
vpcola 0:f1d3878b8dd9 83 echo "*** Deleting a tag is not allowed in this repository" >&2
vpcola 0:f1d3878b8dd9 84 exit 1
vpcola 0:f1d3878b8dd9 85 fi
vpcola 0:f1d3878b8dd9 86 ;;
vpcola 0:f1d3878b8dd9 87 refs/tags/*,tag)
vpcola 0:f1d3878b8dd9 88 # annotated tag
vpcola 0:f1d3878b8dd9 89 if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
vpcola 0:f1d3878b8dd9 90 then
vpcola 0:f1d3878b8dd9 91 echo "*** Tag '$refname' already exists." >&2
vpcola 0:f1d3878b8dd9 92 echo "*** Modifying a tag is not allowed in this repository." >&2
vpcola 0:f1d3878b8dd9 93 exit 1
vpcola 0:f1d3878b8dd9 94 fi
vpcola 0:f1d3878b8dd9 95 ;;
vpcola 0:f1d3878b8dd9 96 refs/heads/*,commit)
vpcola 0:f1d3878b8dd9 97 # branch
vpcola 0:f1d3878b8dd9 98 if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
vpcola 0:f1d3878b8dd9 99 echo "*** Creating a branch is not allowed in this repository" >&2
vpcola 0:f1d3878b8dd9 100 exit 1
vpcola 0:f1d3878b8dd9 101 fi
vpcola 0:f1d3878b8dd9 102 ;;
vpcola 0:f1d3878b8dd9 103 refs/heads/*,delete)
vpcola 0:f1d3878b8dd9 104 # delete branch
vpcola 0:f1d3878b8dd9 105 if [ "$allowdeletebranch" != "true" ]; then
vpcola 0:f1d3878b8dd9 106 echo "*** Deleting a branch is not allowed in this repository" >&2
vpcola 0:f1d3878b8dd9 107 exit 1
vpcola 0:f1d3878b8dd9 108 fi
vpcola 0:f1d3878b8dd9 109 ;;
vpcola 0:f1d3878b8dd9 110 refs/remotes/*,commit)
vpcola 0:f1d3878b8dd9 111 # tracking branch
vpcola 0:f1d3878b8dd9 112 ;;
vpcola 0:f1d3878b8dd9 113 refs/remotes/*,delete)
vpcola 0:f1d3878b8dd9 114 # delete tracking branch
vpcola 0:f1d3878b8dd9 115 if [ "$allowdeletebranch" != "true" ]; then
vpcola 0:f1d3878b8dd9 116 echo "*** Deleting a tracking branch is not allowed in this repository" >&2
vpcola 0:f1d3878b8dd9 117 exit 1
vpcola 0:f1d3878b8dd9 118 fi
vpcola 0:f1d3878b8dd9 119 ;;
vpcola 0:f1d3878b8dd9 120 *)
vpcola 0:f1d3878b8dd9 121 # Anything else (is there anything else?)
vpcola 0:f1d3878b8dd9 122 echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
vpcola 0:f1d3878b8dd9 123 exit 1
vpcola 0:f1d3878b8dd9 124 ;;
vpcola 0:f1d3878b8dd9 125 esac
vpcola 0:f1d3878b8dd9 126
vpcola 0:f1d3878b8dd9 127 # --- Finished
vpcola 0:f1d3878b8dd9 128 exit 0