diff options
author | Joey Hess <joey@kitenet.net> | 2014-10-27 11:09:55 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-10-27 11:09:55 -0400 |
commit | c3b9e3d64ae4082b627ffa50996ee403b09759d5 (patch) | |
tree | 65e650b697c2edd59b91e0b138155548c80173e7 /Build/Version.hs | |
parent | a75b13f2565e7908eb3e86477c447ce7ca575820 (diff) | |
download | git-repair-c3b9e3d64ae4082b627ffa50996ee403b09759d5.tar.gz |
Merge Build/ from git-annex, including removing a use of deprecated System.Cmd.
Diffstat (limited to 'Build/Version.hs')
-rw-r--r-- | Build/Version.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Build/Version.hs b/Build/Version.hs index 98e0dbf..da9d1bb 100644 --- a/Build/Version.hs +++ b/Build/Version.hs @@ -10,10 +10,11 @@ import System.Directory import Data.Char import System.Process -import Build.TestConfig import Utility.Monad import Utility.Exception +type Version = String + {- Set when making an official release. (Distribution vendors should set - this too.) -} isReleaseBuild :: IO Bool @@ -25,14 +26,14 @@ isReleaseBuild = isJust <$> catchMaybeIO (getEnv "RELEASE_BUILD") - - If git or a git repo is not available, or something goes wrong, - or this is a release build, just use the version from the changelog. -} -getVersion :: Test +getVersion :: IO Version getVersion = do changelogversion <- getChangelogVersion - version <- ifM (isReleaseBuild) + ifM (isReleaseBuild) ( return changelogversion , catchDefaultIO changelogversion $ do let major = takeWhile (/= '.') changelogversion - autoversion <- readProcess "sh" + autoversion <- takeWhile (\c -> isAlphaNum c || c == '-') <$> readProcess "sh" [ "-c" , "git log -n 1 --format=format:'%ci %h'| sed -e 's/-//g' -e 's/ .* /-g/'" ] "" @@ -40,9 +41,8 @@ getVersion = do then return changelogversion else return $ concat [ major, ".", autoversion ] ) - return $ Config "packageversion" (StringConfig version) -getChangelogVersion :: IO String +getChangelogVersion :: IO Version getChangelogVersion = do changelog <- readFile "debian/changelog" let verline = takeWhile (/= '\n') changelog |