git-annex/Command/Trust.hs

41 lines
976 B
Haskell
Raw Normal View History

2010-12-28 21:44:55 +00:00
{- git-annex command
-
- Copyright 2010, 2014 Joey Hess <id@joeyh.name>
2010-12-28 21:44:55 +00:00
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Trust where
import Command
import qualified Remote
import Types.TrustLevel
2011-10-15 20:21:08 +00:00
import Logs.Trust
2014-02-20 19:12:35 +00:00
import Logs.Group
import qualified Data.Set as S
2010-12-28 21:44:55 +00:00
cmd :: Command
cmd = command "trust" SectionSetup "trust a repository"
(paramRepeating paramRemote) (withParams seek)
seek :: CmdParams -> CommandSeek
2014-02-20 19:12:35 +00:00
seek = trustCommand "trust" Trusted
2010-12-28 21:44:55 +00:00
trustCommand :: String -> TrustLevel -> CmdParams -> CommandSeek
2014-10-15 18:29:53 +00:00
trustCommand c level = withWords start
2014-02-20 19:12:35 +00:00
where
start ws = do
let name = unwords ws
2014-10-15 18:29:53 +00:00
showStart c name
2014-02-20 19:12:35 +00:00
u <- Remote.nameToUUID name
next $ perform u
perform uuid = do
trustSet uuid level
when (level == DeadTrusted) $
groupSet uuid S.empty
l <- lookupTrust uuid
when (l /= level) $
warning $ "This remote's trust level is locally overridden to " ++ showTrustLevel l ++ " via git config."
2014-02-20 19:12:35 +00:00
next $ return True