FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:37:05 2017 +0000
Revision:
0:dbad57390bd1
Initial commit

Who changed what in which revision?

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