git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] t/t7510-signed-commit.sh: test new placeholders

From
John Passaro <john.a.passaro@gmail.com>
Date
Dec 13, 2018, 21:22 UTC
Message-ID
<20181213212256.48122-3-john.a.passaro@gmail.com>
In-Reply-To
<20181213212256.48122-1-john.a.passaro@gmail.com>

Test that %GR output ("Raw" contents of "gpgsig" header) looks like ASCII-armored GPG signature.

Test %G+ (Y/N for presence/absence of "gpgsig" header) by adding it to existing format tests for signed commits.

Signed-off-by: John Passaro <john.a.passaro@gmail.com>
---
 t/t7510-signed-commit.sh | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 86d3f93fa2..aff6b1eb3a 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -177,8 +177,9 @@ test_expect_success GPG 'show good signature with custom format' '
 	C O Mitter <committer@example.com>
 	73D758744BE721698EC54E8713B6F51ECDDE430D
 	73D758744BE721698EC54E8713B6F51ECDDE430D
+	Y
 	EOF
-	git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" sixth-signed >actual &&
+	git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" sixth-signed >actual &&
 	test_cmp expect actual
 '
 
@@ -189,8 +190,9 @@ test_expect_success GPG 'show bad signature with custom format' '
 	C O Mitter <committer@example.com>
 
 
+	Y
 	EOF
-	git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" $(cat forged1.commit) >actual &&
+	git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" $(cat forged1.commit) >actual &&
 	test_cmp expect actual
 '
 
@@ -201,8 +203,9 @@ test_expect_success GPG 'show untrusted signature with custom format' '
 	Eris Discordia <discord@example.net>
 	F8364A59E07FFE9F4D63005A65A0EEA02E30CAD7
 	D4BE22311AD3131E5EDA29A461092E85B7227189
+	Y
 	EOF
-	git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual &&
+	git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" eighth-signed-alt >actual &&
 	test_cmp expect actual
 '
 
@@ -213,8 +216,9 @@ test_expect_success GPG 'show unknown signature with custom format' '
 
 
 
+	Y
 	EOF
-	GNUPGHOME="$GNUPGHOME_NOT_USED" git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual &&
+	GNUPGHOME="$GNUPGHOME_NOT_USED" git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" eighth-signed-alt >actual &&
 	test_cmp expect actual
 '
 
@@ -225,11 +229,27 @@ test_expect_success GPG 'show lack of signature with custom format' '
 
 
 
+	N
 	EOF
-	git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" seventh-unsigned >actual &&
+	git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" seventh-unsigned >actual &&
 	test_cmp expect actual
 '
 
+test_expect_success GPG 'show lack of raw signature with custom format' '
+	git log -1 --format=format:"%GR" seventh-unsigned > actual &&
+	test_must_be_empty actual
+'
+
+test_expect_success GPG 'show raw signature with custom format' '
+	git log -1 --format=format:"%GR" sixth-signed >output &&
+	cat output &&
+	head -n1 output | grep -q "^---*BEGIN PGP SIGNATURE---*$" &&
+	sed 1d output | grep -q "^$" &&
+	sed "1,/^$/d" output | grep -q "^[a-zA-Z0-9+/][a-zA-Z0-9+/=]*$" &&
+	tail -n2 output | head -n1 | grep -q "^=[a-zA-Z0-9+/][a-zA-Z0-9+/=]*$" &&
+	tail -n1 output | grep -q "^---*END PGP SIGNATURE---*$"
+'
+
 test_expect_success GPG 'log.showsignature behaves like --show-signature' '
 	test_config log.showsignature true &&
 	git show initial >actual &&
-- 
2.19.1
Previous: John PassaroNext: John Passaro
Message 3 of 14 in “Expose gpgsig in pretty-print”
  1. 0/4 Expose gpgsig in pretty-printJohn Passaro, Dec 13, 2018
  2. 1/4 pretty: expose raw commit signatureJohn Passaro, Dec 13, 2018
  3. 2/4 t/t7510-signed-commit.sh: test new placeholdersJohn Passaro, Dec 13, 2018
  4. 3/4 doc, tests: pretty behavior when gpg missingJohn Passaro, Dec 13, 2018
  5. 4/4 docs/pretty-formats: add explanation + copy editsJohn Passaro, Dec 13, 2018
  6. Michał GórnyDec 14, 2018
  7. John PassaroDec 14, 2018
  8. Michał GórnyDec 14, 2018
  9. John PassaroDec 14, 2018
  10. John PassaroDec 14, 2018
  11. Jeff KingDec 17, 2018
  12. John PassaroDec 19, 2018
  13. Michał GórnyDec 21, 2018
  14. Junio C HamanoDec 15, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.