diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-11-08 14:50:21 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-11-08 14:50:21 -0400 |
| commit | d7e140aeae8a8ea47976ca1f3e29c4d0b00eacee (patch) | |
| tree | 31aa4bbf775879dddb307f9d1c99ac84287ca909 /src/Propellor/Gpg.hs | |
| parent | f85b7d1bdc9019fd63c5037094f514a7c7ace8d2 (diff) | |
| parent | d50aa85052b1f35021072ea95bc51b5c46c797b0 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Gpg.hs')
| -rw-r--r-- | src/Propellor/Gpg.hs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/Propellor/Gpg.hs b/src/Propellor/Gpg.hs index 60b0d52d..960c70d3 100644 --- a/src/Propellor/Gpg.hs +++ b/src/Propellor/Gpg.hs @@ -7,6 +7,8 @@ import System.Directory import Data.Maybe import Data.List.Utils import Control.Monad +import System.Console.Concurrent +import System.Console.Concurrent.Internal (ConcurrentProcessHandle(..)) import Propellor.PrivData.Paths import Propellor.Message @@ -111,10 +113,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 +123,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 + (_, _, _, ConcurrentProcessHandle p) <- createProcessForeground $ + proc "git" (toCommand ps'') + checkSuccessProcess p + else boolSystem "git" ps'' gpgDecrypt :: FilePath -> IO String gpgDecrypt f = ifM (doesFileExist f) |
