2010-12-28 21:44:55 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- 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
|
2011-03-27 20:55:43 +00:00
|
|
|
import qualified Remote
|
2014-02-20 19:17:39 +00:00
|
|
|
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
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2015-07-08 19:08:02 +00:00
|
|
|
cmd = command "trust" SectionSetup "trust a repository"
|
|
|
|
(paramRepeating paramRemote) (withParams seek)
|
2010-12-30 19:06:26 +00:00
|
|
|
|
2015-07-08 19:08:02 +00:00
|
|
|
seek :: CmdParams -> CommandSeek
|
2014-02-20 19:12:35 +00:00
|
|
|
seek = trustCommand "trust" Trusted
|
2010-12-28 21:44:55 +00:00
|
|
|
|
2015-07-08 19:08:02 +00:00
|
|
|
trustCommand :: String -> TrustLevel -> CmdParams -> CommandSeek
|
2018-10-01 18:12:06 +00:00
|
|
|
trustCommand c level = withWords (commandAction . start)
|
2014-02-20 19:12:35 +00:00
|
|
|
where
|
|
|
|
start ws = do
|
|
|
|
let name = unwords ws
|
2017-11-28 18:40:26 +00:00
|
|
|
showStart' c (Just 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
|
2014-02-20 19:17:39 +00:00
|
|
|
l <- lookupTrust uuid
|
|
|
|
when (l /= level) $
|
2017-09-13 16:08:46 +00:00
|
|
|
warning $ "This remote's trust level is overridden to " ++ showTrustLevel l ++ "."
|
2014-02-20 19:12:35 +00:00
|
|
|
next $ return True
|