1#!/bin/sh 2# 3# An example hook script to blocks unannotated tags from entering. 4# Called by git-receive-pack with arguments: refname sha1-old sha1-new 5# 6# To enable this hook, make this file executable by "chmod +x update". 7# 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# 14 15# --- Command line 16refname="$1" 17oldrev="$2" 18newrev="$3" 19 20# --- Safety check 21if[-z"$GIT_DIR"];then 22echo"Don't run this script from the command line.">&2 23echo" (if you want, you could supply GIT_DIR then run">&2 24echo"$0<ref> <oldrev> <newrev>)">&2 25exit1 26fi 27 28if[-z"$refname"-o -z"$oldrev"-o -z"$newrev"];then 29echo"Usage:$0<ref> <oldrev> <newrev>">&2 30exit1 31fi 32 33# --- Config 34allowunannotated=$(git-repo-config --bool hooks.allowunannotated) 35 36# check for no description 37projectdesc=$(sed -e '1p' "$GIT_DIR/description") 38if[-z"$projectdesc"-o"$projectdesc"="Unnamed repository; edit this file to name it for gitweb"];then 39echo"*** Project description file hasn't been set">&2 40exit1 41fi 42 43# --- Check types 44newrev_type=$(git-cat-file -t $newrev) 45 46case"$refname","$newrev_type"in 47 refs/tags/*,commit) 48# un-annotated tag 49 short_refname=${refname##refs/tags/} 50if["$allowunannotated"!="true"];then 51echo"*** The un-annotated tag,$short_refname, is not allowed in this repository">&2 52echo"*** Use 'git tag [ -a | -s ]' for tags you want to propagate.">&2 53exit1 54fi 55;; 56 refs/tags/*,tag) 57# annotated tag 58;; 59 refs/heads/*,commit) 60# branch 61;; 62 refs/remotes/*,commit) 63# tracking branch 64;; 65*) 66# Anything else (is there anything else?) 67echo"*** Update hook: unknown type of update to ref$refnameof type$newrev_type">&2 68exit1 69;; 70esac 71 72# --- Finished 73exit0