diff options
| author | Félix Sipma <felix.sipma@no-log.org> | 2016-01-03 16:13:11 +0100 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-01-03 16:35:37 -0400 |
| commit | d5c8e05b750e4251b96becd78bd9faef634482f3 (patch) | |
| tree | a34370435d180fc7dcd531270e4daf1f67120a0b /src/Propellor/Gpg.hs | |
| parent | 93ee9e6966783368fa41fb75c7e287bee04f9c16 (diff) | |
Gpg: use gpg.program from git config
(cherry picked from commit dd572a741f1ca4bce8f984c350d9045d979f1813)
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" |
