summaryrefslogtreecommitdiff
path: root/src/Propellor/Gpg.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2014-11-23 18:49:33 -0400
committerJoey Hess <joey@kitenet.net>2014-11-23 18:49:33 -0400
commitf14749c1ccdaeb76beee74381d86f0bc4bc76b09 (patch)
tree5cff1489e97022ad227de288e470acfe0128df5c /src/Propellor/Gpg.hs
parent1695f5c678e5e64bc12252ee5b8ed75d1c5b5c49 (diff)
parent9d975e9ee4c44782da0815fb161ea8676dbf559c (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Gpg.hs')
-rw-r--r--src/Propellor/Gpg.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Propellor/Gpg.hs b/src/Propellor/Gpg.hs
index 572be190..86f84dc1 100644
--- a/src/Propellor/Gpg.hs
+++ b/src/Propellor/Gpg.hs
@@ -83,14 +83,18 @@ addKey keyid = exitBool =<< allM (uncurry actionMessage)
, Param "propellor addkey"
]
+-- Adds --gpg-sign if there's a keyring.
+gpgSignParams :: [CommandParam] -> IO [CommandParam]
+gpgSignParams ps = ifM (doesFileExist keyring)
+ ( return (ps ++ [Param "--gpg-sign"])
+ , return ps
+ )
+
-- Automatically sign the commit if there'a a keyring.
gitCommit :: [CommandParam] -> IO Bool
gitCommit ps = do
- k <- doesFileExist keyring
- boolSystem "git" $ catMaybes $
- [ Just (Param "commit")
- , if k then Just (Param "--gpg-sign") else Nothing
- ] ++ map Just ps
+ ps' <- gpgSignParams ps
+ boolSystem "git" (Param "commit" : ps')
gpgDecrypt :: FilePath -> IO String
gpgDecrypt f = ifM (doesFileExist f)