git-annex/Command/Trust.hs

42 lines
964 B
Haskell
Raw Normal View History

2010-12-28 17:44:55 -04:00
{- git-annex command
-
2014-02-20 15:12:35 -04:00
- Copyright 2010, 2014 Joey Hess <joey@kitenet.net>
2010-12-28 17:44:55 -04:00
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Trust where
2011-10-05 16:02:51 -04:00
import Common.Annex
2010-12-28 17:44:55 -04:00
import Command
import qualified Remote
import Types.TrustLevel
2011-10-15 16:21:08 -04:00
import Logs.Trust
2014-02-20 15:12:35 -04:00
import Logs.Group
import qualified Data.Set as S
2010-12-28 17:44:55 -04:00
cmd :: [Command]
cmd = [command "trust" (paramRepeating paramRemote) seek
SectionSetup "trust a repository"]
seek :: CommandSeek
2014-02-20 15:12:35 -04:00
seek = trustCommand "trust" Trusted
2010-12-28 17:44:55 -04:00
2014-02-20 15:12:35 -04:00
trustCommand :: String -> TrustLevel -> CommandSeek
2014-10-15 14:29:53 -04:00
trustCommand c level = withWords start
2014-02-20 15:12:35 -04:00
where
start ws = do
let name = unwords ws
2014-10-15 14:29:53 -04:00
showStart c name
2014-02-20 15:12:35 -04: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 15:12:35 -04:00
next $ return True