From 7c12f0ac9224246dac308e837bccb5b2157062ee Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 15 Dec 2015 17:47:59 -0700 Subject: Import git-repair_1.20151215.orig.tar.xz [dgit import orig git-repair_1.20151215.orig.tar.xz] --- Git/Version.hs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Git/Version.hs (limited to 'Git/Version.hs') diff --git a/Git/Version.hs b/Git/Version.hs new file mode 100644 index 0000000..19ff945 --- /dev/null +++ b/Git/Version.hs @@ -0,0 +1,32 @@ +{- git versions + - + - Copyright 2011, 2013 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +{-# OPTIONS_GHC -fno-warn-tabs #-} + +module Git.Version ( + installed, + older, + normalize, + GitVersion, +) where + +import Common +import Utility.DottedVersion + +type GitVersion = DottedVersion + +installed :: IO GitVersion +installed = normalize . extract <$> readProcess "git" ["--version"] + where + extract s = case lines s of + [] -> "" + (l:_) -> unwords $ drop 2 $ words l + +older :: String -> IO Bool +older n = do + v <- installed + return $ v < normalize n -- cgit v1.2.3