Skip to content

Commit 5eb3d94

Browse files
committed
Merge branch 'hv/sample-update'
* hv/sample-update: Extend sample update hook, disable modifying of existing tags
2 parents 2beba6b + 7742c65 commit 5eb3d94

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

templates/hooks--update.sample

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# hooks.allowdeletetag
1414
# This boolean sets whether deleting tags will be allowed in the
1515
# repository. By default they won't be.
16+
# hooks.allowmodifytag
17+
# This boolean sets whether a tag may be modified after creation. By default
18+
# it won't be.
1619
# hooks.allowdeletebranch
1720
# This boolean sets whether deleting branches will be allowed in the
1821
# repository. By default they won't be.
@@ -44,6 +47,7 @@ allowunannotated=$(git config --bool hooks.allowunannotated)
4447
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
4548
denycreatebranch=$(git config --bool hooks.denycreatebranch)
4649
allowdeletetag=$(git config --bool hooks.allowdeletetag)
50+
allowmodifytag=$(git config --bool hooks.allowmodifytag)
4751

4852
# check for no description
4953
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
@@ -82,6 +86,12 @@ case "$refname","$newrev_type" in
8286
;;
8387
refs/tags/*,tag)
8488
# annotated tag
89+
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
90+
then
91+
echo "*** Tag '$refname' already exists." >&2
92+
echo "*** Modifying a tag is not allowed in this repository." >&2
93+
exit 1
94+
fi
8595
;;
8696
refs/heads/*,commit)
8797
# branch

0 commit comments

Comments
 (0)