From bf28d6306e9df825a503f9425c89f215d234f355 Mon Sep 17 00:00:00 2001 From: az Date: Mon, 5 Jun 2023 22:33:48 +0200 Subject: [PATCH] add git init of gopass root dir --- .../provs/desktop/infrastructure/Gopass.kt | 3 +++ .../provs/desktop/infrastructure/GopassKtTest.kt | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt index 0dcdfcb..84ab597 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt @@ -83,6 +83,9 @@ fun Prov.gopassMountStore(storeName: String, path: String) = taskWithResult { fun Prov.gopassInitStoreFolder(path: String, gpgFingerprint: String? = null ) = task { createFile("$path/.gpg-id", gpgFingerprint ?: "_replace_this_by_a_fingerprint_of_a_public_gpg_key_") + if (!checkDir(".git", path)) { + cmd("git init", path) + } } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassKtTest.kt index aa34e22..f192823 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassKtTest.kt @@ -40,9 +40,11 @@ internal class GopassKtTest { installGopass() configureGopass(prov.userHome() + gopassRootDir) gopassInitStoreFolder("~/exampleStoreFolder") + gopassInitStoreFolder("~/exampleStoreFolder") // check idem-potency gopassMountStore("exampleStore", "~/exampleStoreFolder") - gopassMountStore("exampleStore", "~/exampleStoreFolder") // check that mounting twice gives no error + gopassMountStore("exampleStore", "~/exampleStoreFolder") // check idem-potency prov.cmd("gopass ls") + prov.cmd("gopass sync") } // then @@ -50,6 +52,7 @@ internal class GopassKtTest { assertTrue(res.success) assertTrue(prov.fileContainsText("~/.config/gopass/config", "/home/testuser/.password-store")) assertTrue(prov.fileContainsText("~/.config/gopass/config", "exampleStore")) + assertTrue(prov.checkDir(".git", gopassRootDir)) } @Test