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