Skip to content

Commit 4b8d14b

Browse files
boklmgitster
authored andcommitted
test the commit.gpgsign config option
The tests are checking that : - when commit.gpgsign is true, "git commit" creates signed commits - when commit.gpgsign is false, "git commit" creates unsigned commits - when commit.gpgsign is true, "git commit --no-gpg-sign" creates unsigned commits - when commit.gpgsign is true, "git rebase -f" creates signed commits Signed-off-by: Nicolas Vigier <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 55ca3f9 commit 4b8d14b

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

t/t7510-signed-commit.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ test_description='signed commit tests'
55
. "$TEST_DIRECTORY/lib-gpg.sh"
66

77
test_expect_success GPG 'create signed commits' '
8+
test_when_finished "test_unconfig commit.gpgsign" &&
9+
810
echo 1 >file && git add file &&
911
test_tick && git commit -S -m initial &&
1012
git tag initial &&
@@ -25,12 +27,27 @@ test_expect_success GPG 'create signed commits' '
2527
git tag fourth-unsigned &&
2628
2729
test_tick && git commit --amend -S -m "fourth signed" &&
28-
git tag fourth-signed
30+
git tag fourth-signed &&
31+
32+
git config commit.gpgsign true &&
33+
echo 5 >file && test_tick && git commit -a -m "fifth signed" &&
34+
git tag fifth-signed &&
35+
36+
git config commit.gpgsign false &&
37+
echo 6 >file && test_tick && git commit -a -m "sixth" &&
38+
git tag sixth-unsigned &&
39+
40+
git config commit.gpgsign true &&
41+
echo 7 >file && test_tick && git commit -a -m "seventh" --no-gpg-sign &&
42+
git tag seventh-unsigned &&
43+
44+
test_tick && git rebase -f HEAD^^ && git tag sixth-signed HEAD^ &&
45+
git tag seventh-signed
2946
'
3047

3148
test_expect_success GPG 'show signatures' '
3249
(
33-
for commit in initial second merge master
50+
for commit in initial second merge fourth-signed fifth-signed sixth-signed master
3451
do
3552
git show --pretty=short --show-signature $commit >actual &&
3653
grep "Good signature from" actual || exit 1
@@ -39,7 +56,7 @@ test_expect_success GPG 'show signatures' '
3956
done
4057
) &&
4158
(
42-
for commit in merge^2 fourth-unsigned
59+
for commit in merge^2 fourth-unsigned sixth-unsigned seventh-unsigned
4360
do
4461
git show --pretty=short --show-signature $commit >actual &&
4562
grep "Good signature from" actual && exit 1
@@ -52,7 +69,7 @@ test_expect_success GPG 'show signatures' '
5269
test_expect_success GPG 'detect fudged signature' '
5370
git cat-file commit master >raw &&
5471
55-
sed -e "s/fourth signed/4th forged/" raw >forged1 &&
72+
sed -e "s/seventh/7th forged/" raw >forged1 &&
5673
git hash-object -w -t commit forged1 >forged1.commit &&
5774
git show --pretty=short --show-signature $(cat forged1.commit) >actual1 &&
5875
grep "BAD signature from" actual1 &&

0 commit comments

Comments
 (0)