2013-08-02 22:31:01 +00:00
|
|
|
{- git versions
|
2011-12-22 18:59:25 +00:00
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2011, 2013 Joey Hess <id@joeyh.name>
|
2011-12-22 18:59:25 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2011-12-22 18:59:25 +00:00
|
|
|
-}
|
|
|
|
|
2015-05-10 20:38:49 +00:00
|
|
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
|
|
|
|
2014-12-16 18:04:40 +00:00
|
|
|
module Git.Version (
|
|
|
|
installed,
|
2015-01-05 19:54:52 +00:00
|
|
|
older,
|
2014-12-16 18:04:40 +00:00
|
|
|
normalize,
|
|
|
|
GitVersion,
|
|
|
|
) where
|
2011-12-22 18:59:25 +00:00
|
|
|
|
2020-10-29 16:02:46 +00:00
|
|
|
import Utility.Process
|
2014-12-16 18:04:40 +00:00
|
|
|
import Utility.DottedVersion
|
2011-12-22 18:59:25 +00:00
|
|
|
|
2014-12-16 18:04:40 +00:00
|
|
|
type GitVersion = DottedVersion
|
2013-08-02 22:31:01 +00:00
|
|
|
|
|
|
|
installed :: IO GitVersion
|
|
|
|
installed = normalize . extract <$> readProcess "git" ["--version"]
|
|
|
|
where
|
2014-10-09 18:53:13 +00:00
|
|
|
extract s = case lines s of
|
2013-08-02 22:31:01 +00:00
|
|
|
[] -> ""
|
|
|
|
(l:_) -> unwords $ drop 2 $ words l
|
2015-01-05 19:54:52 +00:00
|
|
|
|
|
|
|
older :: String -> IO Bool
|
|
|
|
older n = do
|
|
|
|
v <- installed
|
|
|
|
return $ v < normalize n
|