summaryrefslogtreecommitdiff
path: root/src/Propellor/Git.hs
diff options
context:
space:
mode:
authorJoey Hess2014-11-18 19:43:53 -0400
committerJoey Hess2014-11-18 19:43:53 -0400
commit8b6531ea43e43bd979ad9b8125fc21c6602dea38 (patch)
tree763fb277f391ab28232e23a7a5d86f0b1c71ff1b /src/Propellor/Git.hs
parentc9fed0fdaa103e091fdee4ab4ab94dd921ce174a (diff)
reorg
Diffstat (limited to 'src/Propellor/Git.hs')
-rw-r--r--src/Propellor/Git.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Propellor/Git.hs b/src/Propellor/Git.hs
index 0de82f8a..51ed3df2 100644
--- a/src/Propellor/Git.hs
+++ b/src/Propellor/Git.hs
@@ -1,7 +1,10 @@
module Propellor.Git where
import Propellor
+import Propellor.PrivData.Paths
+import Propellor.Gpg
import Utility.SafeCommand
+import Utility.FileMode
getCurrentBranch :: IO String
getCurrentBranch = takeWhile (/= '\n')
@@ -39,3 +42,23 @@ hasOrigin = do
rs <- lines <$> readProcess "git" ["remote"]
return $ "origin" `elem` rs
+{- To verify origin branch commit's signature, have to convince gpg
+ - to use our keyring.
+ - While running git log. Which has no way to pass options to gpg.
+ - Argh!
+ -}
+verifyOriginBranch :: String -> IO Bool
+verifyOriginBranch originbranch = do
+ let gpgconf = privDataDir </> "gpg.conf"
+ writeFile gpgconf $ unlines
+ [ " keyring " ++ keyring
+ , "no-auto-check-trustdb"
+ ]
+ -- gpg is picky about perms
+ modifyFileMode privDataDir (removeModes otherGroupModes)
+ s <- readProcessEnv "git" ["log", "-n", "1", "--format=%G?", originbranch]
+ (Just [("GNUPGHOME", privDataDir)])
+ nukeFile $ privDataDir </> "trustdb.gpg"
+ nukeFile $ privDataDir </> "pubring.gpg"
+ nukeFile $ privDataDir </> "gpg.conf"
+ return (s == "U\n" || s == "G\n")