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

[PATCH 1/2] t/lib-gpg: add prepare_gnupghome() to create GNUPGHOME dir

From
Todd Zullinger <tmz@pobox.com>
Date
Jul 3, 2024, 15:37 UTC
Message-ID
<20240703153738.916469-2-tmz@pobox.com>
In-Reply-To
<20240703153738.916469-1-tmz@pobox.com>

We create the $GNUPGHOME directory in both the GPG and GPGSSH prereqs. Replace the redundancy with a function.

Use `mkdir -p` to ensure we do not fail if a test includes more than one of these prereqs.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
---
 t/lib-gpg.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index add11e88fc..4e44f182bb 100644
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -9,6 +9,11 @@
 GNUPGHOME="$PWD/gpghome"
 export GNUPGHOME
 
+prepare_gnupghome () {
+	mkdir -p "$GNUPGHOME" &&
+	chmod 0700 "$GNUPGHOME"
+}
+
 test_lazy_prereq GPG '
 	gpg_version=$(gpg --version 2>&1)
 	test $? != 127 || exit 1
@@ -38,8 +43,7 @@ test_lazy_prereq GPG '
 		# To export ownertrust:
 		#	gpg --homedir /tmp/gpghome --export-ownertrust \
 		#		> lib-gpg/ownertrust
-		mkdir "$GNUPGHOME" &&
-		chmod 0700 "$GNUPGHOME" &&
+		prepare_gnupghome &&
 		(gpgconf --kill all || : ) &&
 		gpg --homedir "${GNUPGHOME}" --import \
 			"$TEST_DIRECTORY"/lib-gpg/keyring.gpg &&
@@ -132,8 +136,7 @@ test_lazy_prereq GPGSSH '
 	test $? = 0 || exit 1;
 
 	# Setup some keys and an allowed signers file
-	mkdir -p "${GNUPGHOME}" &&
-	chmod 0700 "${GNUPGHOME}" &&
+	prepare_gnupghome &&
 	(setfacl -k "${GNUPGHOME}" 2>/dev/null || true) &&
 	ssh-keygen -t ed25519 -N "" -C "git ed25519 key" -f "${GPGSSH_KEY_PRIMARY}" >/dev/null &&
 	ssh-keygen -t rsa -b 2048 -N "" -C "git rsa2048 key" -f "${GPGSSH_KEY_SECONDARY}" >/dev/null &&
-- 
2.45.2
Previous: Todd ZullingerNext: Todd Zullinger
Message 2 of 14 in “t/lib-gpg: ensure GNUPGHOME is created as needed”
  1. 0/2 t/lib-gpg: ensure GNUPGHOME is created as neededTodd Zullinger, Jul 3, 2024
  2. 1/2 t/lib-gpg: add prepare_gnupghome() to create GNUPGHOME dirTodd Zullinger, Jul 3, 2024
  3. 2/2 t/lib-gpg: call prepare_gnupghome() in GPG2 prereqTodd Zullinger, Jul 3, 2024
  4. Todd ZullingerJul 3, 2024
  5. Todd ZullingerFeb 28, 2025
  6. Junio C HamanoOct 26, 2025
  7. Eric W. BiedermanOct 27, 2025
  8. Junio C HamanoOct 27, 2025
  9. Eric W. BiedermanOct 27, 2025
  10. Eric W. BiedermanOct 27, 2025
  11. Junio C HamanoOct 27, 2025
  12. t1016-compatObjectFormat: Really freeze time for reproduciblityEric W. Biederman, Oct 28, 2025
  13. Junio C HamanoOct 28, 2025
  14. Todd ZullingerOct 29, 2025

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.