refactor
This commit is contained in:
parent
73ed2f8ec1
commit
ae1e9f921b
4 changed files with 27 additions and 69 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
||||
- Copyright 2010, 2014 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -11,22 +11,27 @@ import Common.Annex
|
|||
import Command
|
||||
import qualified Remote
|
||||
import Logs.Trust
|
||||
import Logs.Group
|
||||
|
||||
import qualified Data.Set as S
|
||||
|
||||
def :: [Command]
|
||||
def = [command "trust" (paramRepeating paramRemote) seek
|
||||
SectionSetup "trust a repository"]
|
||||
|
||||
seek :: CommandSeek
|
||||
seek = withWords start
|
||||
seek = trustCommand "trust" Trusted
|
||||
|
||||
start :: [String] -> CommandStart
|
||||
start ws = do
|
||||
let name = unwords ws
|
||||
showStart "trust" name
|
||||
u <- Remote.nameToUUID name
|
||||
next $ perform u
|
||||
|
||||
perform :: UUID -> CommandPerform
|
||||
perform uuid = do
|
||||
trustSet uuid Trusted
|
||||
next $ return True
|
||||
trustCommand :: String -> TrustLevel -> CommandSeek
|
||||
trustCommand cmd level = withWords start
|
||||
where
|
||||
start ws = do
|
||||
let name = unwords ws
|
||||
showStart cmd name
|
||||
u <- Remote.nameToUUID name
|
||||
next $ perform u
|
||||
perform uuid = do
|
||||
trustSet uuid level
|
||||
when (level == DeadTrusted) $
|
||||
groupSet uuid S.empty
|
||||
next $ return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue