diff options
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 |