diff options
author | Joey Hess <joey@kitenet.net> | 2011-08-17 18:38:26 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-08-17 18:38:26 -0400 |
commit | b7a4ff1c3185404d36d34b372b016be052394a95 (patch) | |
tree | 28953385279993b63c28007dd0cfa5e3ea5e853a /Version.hs | |
parent | 228a724d1d1e1d2f27763bd5f71473acc4d022d9 (diff) |
optimise initialized check
Avoid running external command if annex.version is set.
Diffstat (limited to 'Version.hs')
-rw-r--r-- | Version.hs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/Version.hs b/Version.hs index 44fd2e9de..fcf6bc4d1 100644 --- a/Version.hs +++ b/Version.hs @@ -7,8 +7,6 @@ module Version where -import Control.Monad (unless) - import Types import qualified Annex import qualified Git @@ -39,14 +37,11 @@ getVersion = do setVersion :: Annex () setVersion = setConfig versionField defaultVersion -checkVersion :: Annex () -> Annex () -checkVersion initaction = getVersion >>= handle +checkVersion :: Version -> Annex () +checkVersion v + | v `elem` supportedVersions = return () + | v `elem` upgradableVersions = err "Upgrade this repository: git-annex upgrade" + | otherwise = err "Upgrade git-annex." where - handle Nothing = initaction - handle (Just v) = unless (v `elem` supportedVersions) $ - error $ "Repository version " ++ v ++ - " is not supported. " ++ - msg v - msg v - | v `elem` upgradableVersions = "Upgrade this repository: git-annex upgrade" - | otherwise = "Upgrade git-annex." + err msg = error $ "Repository version " ++ v ++ + " is not supported. " ++ msg |