git-annex/Annex/Version.hs

56 lines
1.2 KiB
Haskell
Raw Normal View History

2010-11-08 20:40:42 +00:00
{- git-annex repository versioning
-
- Copyright 2010-2018 Joey Hess <id@joeyh.name>
2010-11-08 20:40:42 +00:00
-
- Licensed under the GNU AGPL version 3 or higher.
2010-11-08 20:40:42 +00:00
-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
2011-10-04 04:40:47 +00:00
module Annex.Version where
2010-11-08 20:40:42 +00:00
import Annex.Common
import Config
import Git.Types
import Types.RepoVersion
import qualified Annex
2010-11-08 20:40:42 +00:00
import qualified Data.Map as M
defaultVersion :: RepoVersion
defaultVersion = RepoVersion 7
latestVersion :: RepoVersion
latestVersion = RepoVersion 7
supportedVersions :: [RepoVersion]
supportedVersions = map RepoVersion [7]
upgradableVersions :: [RepoVersion]
#ifndef mingw32_HOST_OS
upgradableVersions = map RepoVersion [0..6]
#else
upgradableVersions = map RepoVersion [2..6]
#endif
autoUpgradeableVersions :: M.Map RepoVersion RepoVersion
autoUpgradeableVersions = M.fromList
[ (RepoVersion 3, RepoVersion 5)
, (RepoVersion 4, RepoVersion 5)
, (RepoVersion 5, RepoVersion 6)
, (RepoVersion 6, RepoVersion 7)
]
versionField :: ConfigKey
versionField = annexConfig "version"
2010-11-08 20:40:42 +00:00
getVersion :: Annex (Maybe RepoVersion)
getVersion = annexVersion <$> Annex.getGitConfig
2010-11-08 20:40:42 +00:00
setVersion :: RepoVersion -> Annex ()
setVersion (RepoVersion v) = setConfig versionField (show v)
removeVersion :: Annex ()
removeVersion = unsetConfig versionField