Add support in sample hook script for denying annotated tags.
PATCH 1/1 Add support in sample hook script for denying annotated tags.
--- templates/hooks--update.sample | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
In one project I'm in we are using a centralized Git repository that many developers have access to. As such, we want to prevent tags from being created by push operations and have them created by the administrators.
This is a modification to the sample update hook to allow this to simply be a configuration option.
receive.denyCreate actually seems to be what my project wants, but I can see more fine-grained support being nice-to-have. For example, we might want to allow developers to create branches in a developer-specific namespace but still disallow pushing annotated tags.
templates/hooks--update.sample +9 -0
@@ -7,6 +7,9 @@ # # Config # ------ +# hooks.allowannotated +# This boolean sets whether annotated tags will be allowed into the +# repository. By default they won't be. # hooks.allowunannotated # This boolean sets whether unannotated tags will be allowed into the # repository. By default they won't be.
@@ -43,6 +46,7 @@ if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then fi # --- Config +allowannotated=$(git config --bool hooks.allowannotated) allowunannotated=$(git config --bool hooks.allowunannotated) allowdeletebranch=$(git config --bool hooks.allowdeletebranch) denycreatebranch=$(git config --bool hooks.denycreatebranch)
@@ -86,6 +90,11 @@ case "$refname","$newrev_type" in ;; refs/tags/*,tag) # annotated tag + if [ "$oldrev" = "$zero" -a "$allowannotated" != "true" ]; then + echo "*** Creating a tag is not allowed in this repository" >&2 + exit 1 + fi + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 then echo "*** Tag '$refname' already exists." >&2
Signature · 6 lines
1.7.1 -- Boyd Stephen Smith Jr. ,= ,-_-. =. [email protected] ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/
Hi,
Quoted 11 lines · Boyd Stephen Smith Jr.
Signed-off-by "Boyd Stephen Smith Jr." <[email protected]>--- templates/hooks--update.sample | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)In one project I'm in we are using a centralized Git repository that many developers have access to. As such, we want to prevent tags from being created by push operations and have them created by the administrators.
This is a modification to the sample update hook to allow this to simply be a configuration option.
This kind of justification belongs above the "---", I think.
No opinion on the functionality itself. Just:
templates/hooks--update.sample line 12
Quoted 9 lines
templates/hooks--update.sample +3
-0@@ -7,6 +7,9 @@ # # Config # ------ +# hooks.allowannotated +# This boolean sets whether annotated tags will be allowed into the +# repository. By default they won't be.
hooks.denyannotated (defaulting to false) would be more consistent with hooks.denycreatebranch, no?
Or maybe hooks.denycreatetag --- a situation in which unannotated tags should be allowed but annotated denied seems hard to imagine.
Hope that helps,
Jonathan
Quoted 7 lines · Jonathan Nieder
Quoted 6 lines · Boyd Stephen Smith Jr.
Signed-off-by "Boyd Stephen Smith Jr." <[email protected]>---
templates/hooks--update.sample | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
Quoted 8 lines
Quoted 6 lines
In one project I'm in we are using a centralized Git repository that many developers have access to. As such, we want to prevent tags from being created by push operations and have them created by the administrators.
This is a modification to the sample update hook to allow this to simply be a configuration option.
This kind of justification belongs above the "---", I think.
Eh, poop. I wasn't sure were it went since it's been so long since I sent a patch in. I thought only the "commit message" went above the "---" and my explanation seemed a bit over-long for a commit message.
I'll STFW next time and get it correct; I'd like to make it easy to use git am or git apply on the mail so that it is easier to review.
Quoted 9 lines
No opinion on the functionality itself. Just:
Quoted 8 lines
templates/hooks--update.sample +0
-0@@ -7,6 +7,9 @@ # # Config # ------
Quoted 6 lines
templates/hooks--update.sample line 12
Quoted 3 lines
templates/hooks--update.sample +3
-0+# hooks.allowannotated +# This boolean sets whether annotated tags will be allowed into the +# repository. By default they won't be.hooks.denyannotated (defaulting to false) would be more consistent with hooks.denycreatebranch, no?
Most of the flags were allow* and that seems to be a better way to approach access restrictions like this. denycreatebranch is the odd one out, and I was considering a patch that would change it to an allow* as well.
Still, I'm happy to change the new flag to a deny* if there's consensus that it is better implemented that way.
Quoted 1 line
Or maybe hooks.denycreatetag ---
That's probably better if you think of this as being analogous to denycreatebranch. When I wrote the patch I was thinking of this flag as being analogous to allowunannotated.
Quoted 2 lines
a situation in which unannotated
tags should be allowed but annotated denied seems hard to imagine.
Agreed.
Signature · 4 lines
Boyd Stephen Smith Jr. ,= ,-_-. =. [email protected] ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/