diff options
| author | Todd Zullinger <tmz@pobox.com> | 2024-07-03 11:37:31 -0400 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-10-09 17:58:35 -0700 |
| commit | a35952b493f24941ad47233ac01ac9fea305d07f (patch) | |
| tree | 96f515b66fd59395ea14ac2e8f3272de5a213dc0 | |
| parent | 790a17fb19d6eadd16c52e5d284a5c6921744766 (diff) | |
| download | git-a35952b493f24941ad47233ac01ac9fea305d07f.tar.gz git-a35952b493f24941ad47233ac01ac9fea305d07f.zip | |
t/lib-gpg: add prepare_gnupghome() to create GNUPGHOME dir
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | t/lib-gpg.sh | 11 |
1 files 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 && |
