summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Propellor/Git.hs19
-rw-r--r--src/Propellor/Gpg.hs16
2 files changed, 20 insertions, 15 deletions
diff --git a/src/Propellor/Git.hs b/src/Propellor/Git.hs
index a2f5aef2..3ad8e0f4 100644
--- a/src/Propellor/Git.hs
+++ b/src/Propellor/Git.hs
@@ -6,11 +6,11 @@ import Propellor.Gpg
import Utility.FileMode
getCurrentBranch :: IO String
-getCurrentBranch = takeWhile (/= '\n')
+getCurrentBranch = takeWhile (/= '\n')
<$> readProcess "git" ["symbolic-ref", "--short", "HEAD"]
getCurrentBranchRef :: IO String
-getCurrentBranchRef = takeWhile (/= '\n')
+getCurrentBranchRef = takeWhile (/= '\n')
<$> readProcess "git" ["symbolic-ref", "HEAD"]
getCurrentGitSha1 :: String -> IO String
@@ -29,15 +29,6 @@ setRepoUrl url = do
void $ boolSystem "git" [Param "config", Param (branchval "remote"), Param "origin"]
void $ boolSystem "git" [Param "config", Param (branchval "merge"), Param $ "refs/heads/"++branch]
-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
-
-- `git config --bool propellor.blah` outputs "false" if propellor.blah is unset
-- i.e. the git convention is that the default value of any git-config setting
-- is "false". So we don't need a Maybe Bool here.
@@ -92,9 +83,9 @@ fetchOrigin = do
void $ actionMessage "Pull from central git repository" $
boolSystem "git" [Param "fetch"]
-
+
oldsha <- getCurrentGitSha1 branchref
-
+
whenM (doesFileExist keyring) $
ifM (verifyOriginBranch originbranch)
( do
@@ -103,6 +94,6 @@ fetchOrigin = do
void $ boolSystem "git" [Param "merge", Param originbranch]
, warningMessage $ "git branch " ++ originbranch ++ " is not signed with a trusted gpg key; refusing to deploy it! (Running with previous configuration instead.)"
)
-
+
newsha <- getCurrentGitSha1 branchref
return $ oldsha /= newsha
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"