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