Easily add all supported connectivity methods to your mbed OS project

Dependencies:   type-yd-driver

Committer:
MACRUM
Date:
Wed Jul 12 10:52:58 2017 +0000
Revision:
0:615f90842ce8
Initial commit

Who changed what in which revision?

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