summaryrefslogtreecommitdiff
path: root/t/t7004-tag.sh
diff options
context:
space:
mode:
authorLaurent Arnoud <laurent@spkdev.net>2016-03-22 20:41:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-03-22 22:13:40 (GMT)
commit61c2fe0c2984a7785e2ac803ce33e23663295b24 (patch)
treee455e82404e939e76f7e61e0ed4f1b273cb652cc /t/t7004-tag.sh
parent808ecd4cca75acac5e4868f15d3e647fc73698d3 (diff)
downloadgit-61c2fe0c2984a7785e2ac803ce33e23663295b24.zip
git-61c2fe0c2984a7785e2ac803ce33e23663295b24.tar.gz
git-61c2fe0c2984a7785e2ac803ce33e23663295b24.tar.bz2
tag: add the option to force signing of annotated tags
The `tag.forcesignannotated` configuration variable makes "git tag" that would implicitly create an annotated tag to instead create a signed tag. For example $ git tag -m "This is a message" tag-with-message $ git tag -F message-file tag-with-message would create a signed tag if the configuration variable is in effect. To override this from the command line, the user can explicitly ask for an annotated tag, like so: $ git tag -a -m "This is a message" tag-with-message $ git tag -a -F message-file tag-with-message Creation of a light-weight tag, i.e. $ git tag lightweight is not affected. Signed-off-by: Laurent Arnoud <laurent@spkdev.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7004-tag.sh')
-rwxr-xr-xt/t7004-tag.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index cf3469b..f9b7d79 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -775,6 +775,47 @@ test_expect_success GPG '-s implies annotated tag' '
test_cmp expect actual
'
+get_tag_header forcesignannotated-implied-sign $commit commit $time >expect
+echo "A message" >>expect
+echo '-----BEGIN PGP SIGNATURE-----' >>expect
+test_expect_success GPG \
+ 'git tag -s implied if configured with tag.forcesignannotated' \
+ 'test_config tag.forcesignannotated true &&
+ git tag -m "A message" forcesignannotated-implied-sign &&
+ get_tag_msg forcesignannotated-implied-sign >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success GPG \
+ 'lightweight with no message when configured with tag.forcesignannotated' \
+ 'test_config tag.forcesignannotated true &&
+ git tag forcesignannotated-lightweight &&
+ tag_exists forcesignannotated-lightweight &&
+ test_must_fail git tag -v forcesignannotated-no-message
+'
+
+get_tag_header forcesignannotated-annotate $commit commit $time >expect
+echo "A message" >>expect
+test_expect_success GPG \
+ 'git tag -a disable configured tag.forcesignannotated' \
+ 'test_config tag.forcesignannotated true &&
+ git tag -a -m "A message" forcesignannotated-annotate &&
+ get_tag_msg forcesignannotated-annotate >actual &&
+ test_cmp expect actual &&
+ test_must_fail git tag -v forcesignannotated-annotate
+'
+
+get_tag_header forcesignannotated-disabled $commit commit $time >expect
+echo "A message" >>expect
+echo '-----BEGIN PGP SIGNATURE-----' >>expect
+test_expect_success GPG \
+ 'git tag --sign enable GPG sign' \
+ 'test_config tag.forcesignannotated false &&
+ git tag --sign -m "A message" forcesignannotated-disabled &&
+ get_tag_msg forcesignannotated-disabled >actual &&
+ test_cmp expect actual
+'
+
test_expect_success GPG \
'trying to create a signed tag with non-existing -F file should fail' '
! test -f nonexistingfile &&