diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-08-20 14:52:08 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-08-20 14:52:08 -0400 |
| commit | 5020a86907ade611324c66c82cf4ee074789bdd5 (patch) | |
| tree | 6c1f3e748afe10f1d8d5adf943cd36dae704f4da /src/Propellor | |
| parent | 22e6f0a5082271e844720cab07643ff26679ed0f (diff) | |
add gitVersion
Diffstat (limited to 'src/Propellor')
| -rw-r--r-- | src/Propellor/Git.hs | 13 |
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 |
