From 0d5c4022105a393a4eac76b09940f8b22fa0a56c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 9 Jan 2012 23:31:44 -0400 Subject: Add annex-trustlevel configuration settings, which can be used to override the trust level of a remote. This overrides the trust.log, and is overridden by the command-line trust parameters. It would have been nicer to have Logs.Trust.trustMap just look up the configuration for all remotes, but a dependency loop prevented that (Remotes depends on Logs.Trust in several ways). So instead, look up the configuration when building remotes, storing it in the same forcetrust field used for the command-line trust parameters. --- Config.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Config.hs') diff --git a/Config.hs b/Config.hs index aa8885873..0a7ac0789 100644 --- a/Config.hs +++ b/Config.hs @@ -12,6 +12,8 @@ import qualified Git import qualified Git.Config import qualified Git.Command import qualified Annex +import qualified Logs.Trust +import Types.TrustLevel type ConfigKey = String @@ -30,7 +32,7 @@ getConfig r key def = do def' <- fromRepo $ Git.Config.get ("annex." ++ key) def fromRepo $ Git.Config.get (remoteConfig r key) def' -{- Looks up a per-remote config setting in git config. -} +{- A per-remote config setting in git config. -} remoteConfig :: Git.Repo -> ConfigKey -> String remoteConfig r key = "remote." ++ fromMaybe "" (Git.remoteName r) ++ ".annex-" ++ key @@ -67,9 +69,7 @@ prop_cost_sane = False `notElem` , semiCheapRemoteCost + encryptedRemoteCostAdj < expensiveRemoteCost ] -{- Checks if a repo should be ignored, based either on annex-ignore - - setting, or on command-line options. Allows command-line to override - - annex-ignore. -} +{- Checks if a repo should be ignored. -} repoNotIgnored :: Git.Repo -> Annex Bool repoNotIgnored r = not . Git.configTrue <$> getConfig r "ignore" "false" @@ -83,3 +83,8 @@ getNumCopies v = perhaps (use v) =<< Annex.getState Annex.forcenumcopies readMaybe <$> fromRepo (Git.Config.get config "1") perhaps fallback = maybe fallback (return . id) config = "annex.numcopies" + +{- Gets the trust level set for a remote in git config. -} +getTrustLevel :: Git.Repo -> Annex (Maybe TrustLevel) +getTrustLevel r = maybe Nothing Logs.Trust.trustName <$> + fromRepo (Git.Config.getMaybe (remoteConfig r "trustlevel")) -- cgit v1.2.3