annex.autoupgrade setting

This commit is contained in:
Joey Hess 2013-11-22 16:04:20 -04:00
parent be069bd962
commit 31d43c63a4
4 changed files with 47 additions and 7 deletions

View file

@ -9,6 +9,7 @@ module Types.Distribution where
import Types.Key
import Data.Time.Clock
import Git.Config (isTrue, boolConfig)
data GitAnnexDistribution = GitAnnexDistribution
{ distributionUrl :: String
@ -20,3 +21,18 @@ data GitAnnexDistribution = GitAnnexDistribution
deriving (Read, Show, Eq)
type GitAnnexVersion = String
data AutoUpgrade = AskUpgrade | AutoUpgrade | NoAutoUpgrade
deriving (Eq)
toAutoUpgrade :: (Maybe String) -> AutoUpgrade
toAutoUpgrade Nothing = AskUpgrade
toAutoUpgrade (Just s)
| s == "ask" = AskUpgrade
| isTrue s == Just True = AutoUpgrade
| otherwise = NoAutoUpgrade
fromAutoUpgrade :: AutoUpgrade -> String
fromAutoUpgrade AskUpgrade = "ask"
fromAutoUpgrade AutoUpgrade = boolConfig True
fromAutoUpgrade NoAutoUpgrade = boolConfig False

View file

@ -17,6 +17,7 @@ import qualified Git
import qualified Git.Config
import Utility.DataUnits
import Config.Cost
import Types.Distribution
{- Main git-annex settings. Each setting corresponds to a git-config key
- such as annex.foo -}
@ -42,6 +43,7 @@ data GitConfig = GitConfig
, annexCrippledFileSystem :: Bool
, annexLargeFiles :: Maybe String
, annexFsckNudge :: Bool
, annexAutoUpgrade :: AutoUpgrade
, coreSymlinks :: Bool
, gcryptId :: Maybe String
}
@ -70,6 +72,7 @@ extractGitConfig r = GitConfig
, annexCrippledFileSystem = getbool (annex "crippledfilesystem") False
, annexLargeFiles = getmaybe (annex "largefiles")
, annexFsckNudge = getbool (annex "fscknudge") True
, annexAutoUpgrade = toAutoUpgrade $ getmaybe (annex "autoupgrade")
, coreSymlinks = getbool "core.symlinks" True
, gcryptId = getmaybe "core.gcrypt-id"
}