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
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2010-12-28 21:44:55 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
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
|
|
|
|
u <- Remote.nameToUUID name
|
2020-09-14 20:49:33 +00:00
|
|
|
let si = SeekInput ws
|
|
|
|
starting c (ActionItemOther (Just name)) si (perform u)
|
2014-02-20 19:12:35 +00:00
|
|
|
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
|