CoolFace
Apppublic

osanseviero/example-test3

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
update.sample129 linesDownload Raw Back to root
1#!/bin/sh2#3# An example hook script to block unannotated tags from entering.4# Called by "git receive-pack" with arguments: refname sha1-old sha1-new5#6# To enable this hook, rename this file to "update".7#8# Config9# ------10# hooks.allowunannotated11#   This boolean sets whether unannotated tags will be allowed into the12#   repository.  By default they won't be.13# hooks.allowdeletetag14#   This boolean sets whether deleting tags will be allowed in the15#   repository.  By default they won't be.16# hooks.allowmodifytag17#   This boolean sets whether a tag may be modified after creation. By default18#   it won't be.19# hooks.allowdeletebranch20#   This boolean sets whether deleting branches will be allowed in the21#   repository.  By default they won't be.22# hooks.denycreatebranch23#   This boolean sets whether remotely creating branches will be denied24#   in the repository.  By default this is allowed.25#26 27# --- Command line28refname="$1"29oldrev="$2"30newrev="$3"31 32# --- Safety check33if [ -z "$GIT_DIR" ]; then34	echo "Don't run this script from the command line." >&235	echo " (if you want, you could supply GIT_DIR then run" >&236	echo "  $0 <ref> <oldrev> <newrev>)" >&237	exit 138fi39 40if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then41	echo "usage: $0 <ref> <oldrev> <newrev>" >&242	exit 143fi44 45# --- Config46allowunannotated=$(git config --bool hooks.allowunannotated)47allowdeletebranch=$(git config --bool hooks.allowdeletebranch)48denycreatebranch=$(git config --bool hooks.denycreatebranch)49allowdeletetag=$(git config --bool hooks.allowdeletetag)50allowmodifytag=$(git config --bool hooks.allowmodifytag)51 52# check for no description53projectdesc=$(sed -e '1q' "$GIT_DIR/description")54case "$projectdesc" in55"Unnamed repository"* | "")56	echo "*** Project description file hasn't been set" >&257	exit 158	;;59esac60 61# --- Check types62# if $newrev is 0000...0000, it's a commit to delete a ref.63zero="0000000000000000000000000000000000000000"64if [ "$newrev" = "$zero" ]; then65	newrev_type=delete66else67	newrev_type=$(git cat-file -t $newrev)68fi69 70case "$refname","$newrev_type" in71	refs/tags/*,commit)72		# un-annotated tag73		short_refname=${refname##refs/tags/}74		if [ "$allowunannotated" != "true" ]; then75			echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&276			echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&277			exit 178		fi79		;;80	refs/tags/*,delete)81		# delete tag82		if [ "$allowdeletetag" != "true" ]; then83			echo "*** Deleting a tag is not allowed in this repository" >&284			exit 185		fi86		;;87	refs/tags/*,tag)88		# annotated tag89		if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&190		then91			echo "*** Tag '$refname' already exists." >&292			echo "*** Modifying a tag is not allowed in this repository." >&293			exit 194		fi95		;;96	refs/heads/*,commit)97		# branch98		if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then99			echo "*** Creating a branch is not allowed in this repository" >&2100			exit 1101		fi102		;;103	refs/heads/*,delete)104		# delete branch105		if [ "$allowdeletebranch" != "true" ]; then106			echo "*** Deleting a branch is not allowed in this repository" >&2107			exit 1108		fi109		;;110	refs/remotes/*,commit)111		# tracking branch112		;;113	refs/remotes/*,delete)114		# delete tracking branch115		if [ "$allowdeletebranch" != "true" ]; then116			echo "*** Deleting a tracking branch is not allowed in this repository" >&2117			exit 1118		fi119		;;120	*)121		# Anything else (is there anything else?)122		echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2123		exit 1124		;;125esac126 127# --- Finished128exit 0129