Skip track checks for merge-commit.
[git-scripts.git] / update
blob3522aa7a088eb776ca6ac45c40eedb88cc245255
1 #!/bin/sh
3 # An example hook script to blocks unannotated tags from entering.
4 # Called by git-receive-pack with arguments: refname sha1-old sha1-new
6 # To enable this hook, make this file executable by "chmod +x update".
8 # Config
9 # ------
10 # hooks.allowunannotated
11 # This boolean sets whether unannotated tags will be allowed into the
12 # repository. By default they won't be.
13 # hooks.allowdeletetag
14 # This boolean sets whether deleting tags will be allowed in the
15 # repository. By default they won't be.
16 # hooks.allowdeletebranch
17 # This boolean sets whether deleting branches will be allowed in the
18 # repository. By default they won't be.
21 . /home/git/scripts/git-hook-support.sh
23 # --- Command line
24 refname="$1"
25 oldrev="$2"
26 newrev="$3"
28 # --- Safety check
29 if [ -z "$GIT_DIR" ]; then
30 echo "Don't run this script from the command line." >&2
31 echo " (if you want, you could supply GIT_DIR then run" >&2
32 echo " $0 <ref> <oldrev> <newrev>)" >&2
33 exit 1
36 if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
37 echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
38 exit 1
41 # --- Config
42 allowunannotated=$(git config --bool hooks.allowunannotated)
43 allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
44 allowdeletetag=$(git config --bool hooks.allowdeletetag)
46 # check for no description
47 projectdesc=$(sed -e '1q' "$GIT_DIR/description")
48 if [ -z "$projectdesc" -o "$projectdesc" = "Unnamed repository; edit this file to name it for gitweb." ]; then
49 echo "*** Project description file hasn't been set" >&2
50 exit 1
53 check_commit() {
54 exit_status=0
56 check_style $oldrev $newrev
58 if [ $? = 1 ]; then
59 exit_status=1
60 fi;
62 trac_update_check_log $oldrev $newrev "gtest"
64 if [ $? = 1 ]; then
65 exit_status=1
66 fi;
68 exit $exit_status
71 # --- Check types
72 # if $newrev is 0000...0000, it's a commit to delete a ref.
73 if [ "$newrev" = "0000000000000000000000000000000000000000" ]; then
74 newrev_type=delete
75 else
76 newrev_type=$(git-cat-file -t $newrev)
79 case "$refname","$newrev_type" in
80 refs/tags/*,commit)
81 # un-annotated tag
82 short_refname=${refname##refs/tags/}
83 if [ "$allowunannotated" != "true" ]; then
84 echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
85 echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
86 exit 1
89 refs/tags/*,delete)
90 # delete tag
91 if [ "$allowdeletetag" != "true" ]; then
92 echo "*** Deleting a tag is not allowed in this repository" >&2
93 exit 1
96 refs/tags/*,tag)
97 # annotated tag
99 refs/heads/*,commit)
100 # branch
101 check_commit
103 refs/heads/*,delete)
104 # delete branch
105 if [ "$allowdeletebranch" != "true" ]; then
106 echo "*** Deleting a branch is not allowed in this repository" >&2
107 exit 1
110 refs/remotes/*,commit)
111 # tracking branch
113 refs/remotes/*,delete)
114 # delete tracking branch
115 if [ "$allowdeletebranch" != "true" ]; then
116 echo "*** Deleting a tracking branch is not allowed in this repository" >&2
117 exit 1
121 # Anything else (is there anything else?)
122 echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
123 exit 1
125 esac
127 # --- Finished
128 exit 0