diff options
Diffstat (limited to 'src/Propellor/Gpg.hs')
| -rw-r--r-- | src/Propellor/Gpg.hs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Propellor/Gpg.hs b/src/Propellor/Gpg.hs index 4c7ccc9c..0fd8c9ce 100644 --- a/src/Propellor/Gpg.hs +++ b/src/Propellor/Gpg.hs @@ -13,6 +13,7 @@ import Prelude import Propellor.PrivData.Paths import Propellor.Message +import Utility.Exception import Utility.SafeCommand import Utility.Process import Utility.Monad @@ -22,7 +23,11 @@ import Utility.FileSystemEncoding import Utility.Env getGpgBin :: IO String -getGpgBin = getEnvDefault "GNUPGBIN" "gpg" +getGpgBin = do + gitGpgBin <- getGitConfigValue "gpg.program" + case gitGpgBin of + Nothing -> getEnvDefault "GNUPGBIN" "gpg" + Just b -> return b type KeyId = String @@ -113,6 +118,15 @@ reencryptPrivData = ifM (doesFileExist privDataFile) , return True ) +getGitConfigValue :: String -> IO (Maybe String) +getGitConfigValue key = do + value <- catchMaybeIO $ + takeWhile (/= '\n') + <$> readProcess "git" ["config", key] + return $ case value of + Just v | not (null v) -> Just v + _ -> Nothing + gitAdd :: FilePath -> IO Bool gitAdd f = boolSystem "git" [ Param "add" |
