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