Fork of my original MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:43:14 2017 +0000
Revision:
0:a1734fe1ec4b
Initial commit

Who changed what in which revision?

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