summaryrefslogtreecommitdiff
path: root/src/Propellor/Gpg.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Gpg.hs')
-rw-r--r--src/Propellor/Gpg.hs21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/Propellor/Gpg.hs b/src/Propellor/Gpg.hs
index 60b0d52d..9c58a5d1 100644
--- a/src/Propellor/Gpg.hs
+++ b/src/Propellor/Gpg.hs
@@ -16,6 +16,7 @@ import Utility.Monad
import Utility.Misc
import Utility.Tmp
import Utility.FileSystemEncoding
+import Utility.ConcurrentOutput
type KeyId = String
@@ -111,10 +112,7 @@ 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)
- ]
+ gitCommit (Just ("propellor " ++ action)) (map File tocommit)
-- Adds --gpg-sign if there's a keyring.
gpgSignParams :: [CommandParam] -> IO [CommandParam]
@@ -124,10 +122,17 @@ gpgSignParams ps = ifM (doesFileExist keyring)
)
-- Automatically sign the commit if there'a a keyring.
-gitCommit :: [CommandParam] -> IO Bool
-gitCommit ps = do
- ps' <- gpgSignParams ps
- boolSystem "git" (Param "commit" : ps')
+gitCommit :: Maybe String -> [CommandParam] -> IO Bool
+gitCommit msg ps = do
+ let ps' = Param "commit" : ps ++
+ maybe [] (\m -> [Param "-m", Param m]) msg
+ ps'' <- gpgSignParams ps'
+ if isNothing msg
+ then do
+ (_, _, _, p) <- createProcessForeground $
+ proc "git" (toCommand ps'')
+ checkSuccessProcess p
+ else boolSystem "git" ps''
gpgDecrypt :: FilePath -> IO String
gpgDecrypt f = ifM (doesFileExist f)