You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
2.8 KiB
108 lines
2.8 KiB
20 years ago
|
#!/bin/sh
|
||
|
#
|
||
18 years ago
|
# An example hook script to blocks unannotated tags from entering.
|
||
20 years ago
|
# Called by git-receive-pack with arguments: refname sha1-old sha1-new
|
||
20 years ago
|
#
|
||
17 years ago
|
# To enable this hook, rename this file to "update".
|
||
20 years ago
|
#
|
||
18 years ago
|
# Config
|
||
|
# ------
|
||
|
# hooks.allowunannotated
|
||
|
# This boolean sets whether unannotated tags will be allowed into the
|
||
|
# repository. By default they won't be.
|
||
17 years ago
|
# hooks.allowdeletetag
|
||
|
# This boolean sets whether deleting tags will be allowed in the
|
||
|
# repository. By default they won't be.
|
||
|
# hooks.allowdeletebranch
|
||
|
# This boolean sets whether deleting branches will be allowed in the
|
||
|
# repository. By default they won't be.
|
||
18 years ago
|
#
|
||
|
|
||
|
# --- Command line
|
||
|
refname="$1"
|
||
|
oldrev="$2"
|
||
|
newrev="$3"
|
||
|
|
||
|
# --- Safety check
|
||
|
if [ -z "$GIT_DIR" ]; then
|
||
|
echo "Don't run this script from the command line." >&2
|
||
|
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||
|
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
||
|
echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# --- Config
|
||
17 years ago
|
allowunannotated=$(git config --bool hooks.allowunannotated)
|
||
|
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
|
||
|
allowdeletetag=$(git config --bool hooks.allowdeletetag)
|
||
19 years ago
|
|
||
18 years ago
|
# check for no description
|
||
17 years ago
|
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
||
|
if [ -z "$projectdesc" -o "$projectdesc" = "Unnamed repository; edit this file to name it for gitweb." ]; then
|
||
18 years ago
|
echo "*** Project description file hasn't been set" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
18 years ago
|
# --- Check types
|
||
17 years ago
|
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
||
18 years ago
|
if [ "$newrev" = "0000000000000000000000000000000000000000" ]; then
|
||
17 years ago
|
newrev_type=delete
|
||
18 years ago
|
else
|
||
|
newrev_type=$(git-cat-file -t $newrev)
|
||
|
fi
|
||
18 years ago
|
|
||
|
case "$refname","$newrev_type" in
|
||
|
refs/tags/*,commit)
|
||
18 years ago
|
# un-annotated tag
|
||
18 years ago
|
short_refname=${refname##refs/tags/}
|
||
18 years ago
|
if [ "$allowunannotated" != "true" ]; then
|
||
18 years ago
|
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||
18 years ago
|
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||
|
exit 1
|
||
19 years ago
|
fi
|
||
18 years ago
|
;;
|
||
17 years ago
|
refs/tags/*,delete)
|
||
|
# delete tag
|
||
|
if [ "$allowdeletetag" != "true" ]; then
|
||
|
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
;;
|
||
18 years ago
|
refs/tags/*,tag)
|
||
|
# annotated tag
|
||
19 years ago
|
;;
|
||
18 years ago
|
refs/heads/*,commit)
|
||
|
# branch
|
||
|
;;
|
||
17 years ago
|
refs/heads/*,delete)
|
||
|
# delete branch
|
||
|
if [ "$allowdeletebranch" != "true" ]; then
|
||
|
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
;;
|
||
18 years ago
|
refs/remotes/*,commit)
|
||
|
# tracking branch
|
||
|
;;
|
||
17 years ago
|
refs/remotes/*,delete)
|
||
|
# delete tracking branch
|
||
|
if [ "$allowdeletebranch" != "true" ]; then
|
||
|
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
;;
|
||
18 years ago
|
*)
|
||
|
# Anything else (is there anything else?)
|
||
18 years ago
|
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||
18 years ago
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
# --- Finished
|
||
20 years ago
|
exit 0
|