| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# This hook is called with the following parameters: |
| 4 |
# |
| 5 |
# $1 -- Name of the remote to which the push is being done |
| 6 |
# $2 -- URL to which the push is being done |
| 7 |
# |
| 8 |
# If pushing without using a named remote those arguments will be equal. |
| 9 |
# |
| 10 |
# Information about the commits which are being pushed is supplied as lines to |
| 11 |
# the standard input in the form: |
| 12 |
# |
| 13 |
# <local ref> <local sha1> <remote ref> <remote sha1> |
| 14 |
|
| 15 |
exitcode=0 |
| 16 |
die() { |
| 17 |
echo "(pre-push) $@" >&2 |
| 18 |
exitcode=1 |
| 19 |
} |
| 20 |
|
| 21 |
remote="$1" |
| 22 |
url="$2" |
| 23 |
|
| 24 |
z40=0000000000000000000000000000000000000000 |
| 25 |
|
| 26 |
IFS=' ' |
| 27 |
while read local_ref local_sha remote_ref remote_sha |
| 28 |
do |
| 29 |
case "$local_ref" in |
| 30 |
refs/tags/[0-9]*) |
| 31 |
tag="${local_ref/refs\/tags\//}" |
| 32 |
# Mistakes I commonly make: |
| 33 |
# - Not updating CHANGES |
| 34 |
git show $local_sha:CHANGES | grep -q "^Version $tag" || die "Tag $tag not found in CHANGES" |
| 35 |
# - Not using an annotated tag |
| 36 |
test $(git cat-file -t "$local_ref") = "tag" || die "Tag $tag is not annotated" |
| 37 |
;; |
| 38 |
esac |
| 39 |
done |
| 40 |
|
| 41 |
exit $exitcode |