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

[PATCH 2/2] t6300: test new content:* for-each-ref placeholders

From
Jeff King <peff@peff.net>
Date
Aug 31, 2011, 16:44 UTC
Message-ID
<20110831164458.GB10169@sigill.intra.peff.net>
In-Reply-To
<20110831164233.GA4356@sigill.intra.peff.net>

For commits and unsigned tags, these are the same as %(body) and %(subject). This patch also introduces a signed tag and checks for-each-ref's output.

These tests would fit better near the top of the script; however, creating the extra tag throws off the output of later tests. Those tests can't just be adjusted to the new output, either, as the presence of the signed tag depends on the GPG prerequisite.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/lib-gpg.sh            |    8 ++++++++
 t/t6300-for-each-ref.sh |   44 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 28463fb..05824fa 100755
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -24,3 +24,11 @@ else
 		;;
 	esac
 fi
+
+sanitize_pgp() {
+	perl -ne '
+		/^-----END PGP/ and $in_pgp = 0;
+		print unless $in_pgp;
+		/^-----BEGIN PGP/ and $in_pgp = 1;
+	'
+}
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 7dc8a51..24f39de 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -6,6 +6,7 @@
 test_description='for-each-ref test'
 
 . ./test-lib.sh
+. ../lib-gpg.sh
 
 # Mon Jul 3 15:18:43 2006 +0000
 datestamp=1151939923
@@ -35,13 +36,15 @@ test_expect_success 'Create upstream config' '
 
 test_atom() {
 	case "$1" in
-		head) ref=refs/heads/master ;;
-		 tag) ref=refs/tags/testtag ;;
+		head) ref=refs/heads/master; prereq= ;;
+		 tag) ref=refs/tags/testtag; prereq= ;;
+	      signed) ref=refs/tags/signed-tag; prereq=GPG ;;
 	esac
 	printf '%s\n' "$3" >expected
-	test_expect_${4:-success} "basic atom: $1 $2" "
+	test_expect_${4:-success} $prereq "basic atom: $1 $2" "
 		git for-each-ref --format='%($2)' $ref >actual &&
-		test_cmp expected actual
+		sanitize_pgp <actual >actual.clean &&
+		test_cmp expected actual.clean
 	"
 }
 
@@ -71,7 +74,10 @@ test_atom head taggerdate ''
 test_atom head creator 'C O Mitter <committer@example.com> 1151939923 +0200'
 test_atom head creatordate 'Mon Jul 3 17:18:43 2006 +0200'
 test_atom head subject 'Initial'
+test_atom head contents:subject 'Initial'
 test_atom head body ''
+test_atom head contents:body ''
+test_atom head contents:signature ''
 test_atom head contents 'Initial
 '
 
@@ -101,7 +107,10 @@ test_atom tag taggerdate 'Mon Jul 3 17:18:45 2006 +0200'
 test_atom tag creator 'C O Mitter <committer@example.com> 1151939925 +0200'
 test_atom tag creatordate 'Mon Jul 3 17:18:45 2006 +0200'
 test_atom tag subject 'Tagging at 1151939927'
+test_atom tag contents:subject 'Tagging at 1151939927'
 test_atom tag body ''
+test_atom tag contents:body ''
+test_atom tag contents:signature ''
 test_atom tag contents 'Tagging at 1151939927
 '
 
@@ -359,4 +368,31 @@ test_expect_success 'an unusual tag with an incomplete line' '
 
 '
 
+test_expect_success GPG 'create signed tag' '
+	cat <<-\EOF |
+	subject line
+
+	body contents
+	EOF
+	git tag -s -F - signed-tag
+'
+
+test_atom signed contents 'subject line
+
+body contents
+-----BEGIN PGP SIGNATURE-----
+-----END PGP SIGNATURE-----
+'
+test_atom signed body 'body contents
+-----BEGIN PGP SIGNATURE-----
+-----END PGP SIGNATURE-----
+'
+test_atom signed contents:body 'body contents
+'
+test_atom signed contents:subject 'subject line'
+test_atom signed subject 'subject line'
+test_atom signed contents:signature '-----BEGIN PGP SIGNATURE-----
+-----END PGP SIGNATURE-----
+'
+
 test_done
-- 
1.7.6.10.g62f04
Previous: Jeff KingNext: Junio C Hamano
Message 13 of 32 in “More formatting with 'git tag -l'”
  1. Michał GórnyAug 29, 2011
  2. Jeff KingAug 29, 2011
  3. Michał GórnyAug 29, 2011
  4. Jeff KingAug 29, 2011
  5. Michał GórnyAug 29, 2011
  6. git-for-each-ref: move GPG sigs off %(body) to %(signature).Michał Górny, Aug 30, 2011
  7. Michael J GruberAug 30, 2011
  8. Michał GórnyAug 30, 2011
  9. Jeff KingAug 30, 2011
  10. for-each-ref: add split message parts to %(contents:*).Michał Górny, Aug 31, 2011
  11. Jeff KingAug 31, 2011
  12. 1/2 t7004: factor out gpg setupJeff King, Aug 31, 2011
  13. 2/2 t6300: test new content:* for-each-ref placeholdersJeff King, Aug 31, 2011
  14. Junio C HamanoAug 31, 2011
  15. Jeff KingAug 31, 2011
  16. Michał GórnySep 1, 2011
  17. Junio C HamanoSep 1, 2011
  18. Jeff KingSep 1, 2011
  19. Michał GórnySep 1, 2011
  20. for-each-ref: add split message parts to %(contents:*).Michał Górny, Sep 1, 2011
  21. Jeff KingSep 2, 2011
  22. Michał GórnySep 2, 2011
  23. Jeff KingSep 2, 2011
  24. Jeff KingSep 7, 2011
  25. Michał GórnySep 15, 2011
  26. 1/5 t7004: factor out gpg setupJeff King, Sep 7, 2011
  27. 2/5 t6300: add more body-parsing testsJeff King, Sep 7, 2011
  28. 3/5 for-each-ref: refactor subject and body placeholder parsingJeff King, Sep 7, 2011
  29. 4/5 for-each-ref: handle multiline subjects like --prettyJeff King, Sep 7, 2011
  30. 5/5 for-each-ref: add split message parts to %(contents:*).Jeff King, Sep 7, 2011
  31. Junio C HamanoSep 1, 2011
  32. Jeff KingSep 1, 2011

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.