summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2015-10-04 13:50:49 -0400
committerJoey Hess2015-10-04 13:50:49 -0400
commit1a9ce1af5a1d6c2aca063ed2f6e0bd13d1391192 (patch)
tree7a4297baf3496042b2edb8db56c40d6513a528ca
parent0a13fe40308703731d1d803583de01c99637fedd (diff)
Fix --add-key to not fail committing when no privdata file exists yet.
-rw-r--r--debian/changelog1
-rw-r--r--src/Propellor/Gpg.hs15
2 files changed, 10 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog
index e77c5020..bffa070d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ propellor (2.8.1) UNRELEASED; urgency=medium
passwords for a user in different containers. Note that previously,
propellor would prompt using the container name as the context, but
not actually use privdata using that context; so this is a bug fix.
+ * Fix --add-key to not fail committing when no privdata file exists yet.
-- Joey Hess <id@joeyh.name> Fri, 25 Sep 2015 09:21:41 -0400
diff --git a/src/Propellor/Gpg.hs b/src/Propellor/Gpg.hs
index 84f67dc1..60b0d52d 100644
--- a/src/Propellor/Gpg.hs
+++ b/src/Propellor/Gpg.hs
@@ -6,6 +6,7 @@ import System.FilePath
import System.Directory
import Data.Maybe
import Data.List.Utils
+import Control.Monad
import Propellor.PrivData.Paths
import Propellor.Message
@@ -106,12 +107,14 @@ gitAdd f = boolSystem "git"
]
gitCommitKeyRing :: String -> IO Bool
-gitCommitKeyRing action = gitCommit
- [ File keyring
- , File privDataFile
- , Param "-m"
- , Param ("propellor " ++ action)
- ]
+gitCommitKeyRing action = do
+ -- Commit explicitly the keyring and privdata files, as other
+ -- changes may be staged by the user and shouldn't be committed.
+ tocommit <- filterM doesFileExist [ privDataFile, keyring]
+ gitCommit $ (map File tocommit) ++
+ [ Param "-m"
+ , Param ("propellor " ++ action)
+ ]
-- Adds --gpg-sign if there's a keyring.
gpgSignParams :: [CommandParam] -> IO [CommandParam]