summaryrefslogtreecommitdiff
path: root/src/Propellor/Git.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Git.hs')
-rw-r--r--src/Propellor/Git.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Propellor/Git.hs b/src/Propellor/Git.hs
index c3257b31..1d81c157 100644
--- a/src/Propellor/Git.hs
+++ b/src/Propellor/Git.hs
@@ -3,7 +3,10 @@ module Propellor.Git where
import Utility.Process
import Utility.Exception
import Utility.Directory
+import Utility.Misc
+import Utility.PartialPrelude
+import Data.Maybe
import Control.Applicative
import Prelude
@@ -26,3 +29,13 @@ hasOrigin = catchDefaultIO False $ do
hasGitRepo :: IO Bool
hasGitRepo = doesFileExist ".git/HEAD"
+
+type Version = [Int]
+
+gitVersion :: IO Version
+gitVersion = extract <$> readProcess "git" ["--version"]
+ where
+ extract s = case lines s of
+ [] -> []
+ (l:_) -> mapMaybe readish $ segment (== '.') $
+ unwords $ drop 2 $ words l