From: Julian Andres Klode <jak@debian.org>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Julian Andres Klode <jak@debian.org>
Subject: [PATCH] hooks/update: Add a hooks.denyunsignedtags option
Date: Mon, 21 Dec 2015 18:32:04 +0100 [thread overview]
Message-ID: <1450719124-10558-1-git-send-email-jak@debian.org> (raw)
Introduce an option to deny unsigned tags from entering
a repository. This is useful in teams where members forget
to sign their release tags.
It does not actually check whether the signature is actually
complete or valid, it just checks for the beginning of a
signature, as further checks would be too involved.
This effectively also denies un-annotated tags, as those
are unsigned by definition.
Signed-off-by: Julian Andres Klode <jak@debian.org>
---
Note: Submitted for review on Sep 12, re-asked on Sep 22, but
no feedback, so I assume it's good to go, see
http://thread.gmane.org/gmane.comp.version-control.git/277722
for details
templates/hooks--update.sample | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample
index d847583..e261d30 100755
--- a/templates/hooks--update.sample
+++ b/templates/hooks--update.sample
@@ -16,6 +16,9 @@
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
+# hooks.denyunsignedtag
+# This boolean sets whether creating unsigned tags will be denied. By
+# default this is allowed.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
@@ -48,6 +51,7 @@ allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
denycreatebranch=$(git config --bool hooks.denycreatebranch)
allowdeletetag=$(git config --bool hooks.allowdeletetag)
allowmodifytag=$(git config --bool hooks.allowmodifytag)
+denyunsignedtag=$(git config --bool hooks.denyunsignedtag)
# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
@@ -71,7 +75,7 @@ case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
- if [ "$allowunannotated" != "true" ]; then
+ if [ "$allowunannotated" != "true" ] || [ "$denyunsignedtag" = "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
@@ -86,6 +90,14 @@ case "$refname","$newrev_type" in
;;
refs/tags/*,tag)
# annotated tag
+ if [ "$denyunsignedtag" != "true" ] || git cat-file -p $newrev | grep -q 'BEGIN PGP SIGNATURE'; then
+ :
+ else
+ echo "*** Tag '$refname' is unsigned"
+ echo "*** Unsigned tags are 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
--
2.6.4
next reply other threads:[~2015-12-21 17:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-21 17:32 Julian Andres Klode [this message]
2015-12-21 18:13 ` [PATCH] hooks/update: Add a hooks.denyunsignedtags option Junio C Hamano
2015-12-21 18:52 ` Junio C Hamano
2015-12-21 19:29 ` Eric Sunshine
-- strict thread matches above, loose matches on Subject: below --
2015-09-12 10:37 Julian Andres Klode
2015-09-12 10:40 ` Julian Andres Klode
2015-09-22 18:42 ` Julian Andres Klode
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450719124-10558-1-git-send-email-jak@debian.org \
--to=jak@debian.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).