summaryrefslogtreecommitdiff
path: root/Command/Trust.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-20 15:12:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-20 15:12:35 -0400
commitcfdcf25d13eaa2a6a8b2601a50fda4370645c639 (patch)
tree2974ca42fe2262805a96f588033ba4ffd8ecc1ee /Command/Trust.hs
parent1c8c95915c3e234a3c8d24a4f5218a913239e15f (diff)
refactor
Diffstat (limited to 'Command/Trust.hs')
-rw-r--r--Command/Trust.hs31
1 files changed, 18 insertions, 13 deletions
diff --git a/Command/Trust.hs b/Command/Trust.hs
index 3898af347..6f7d6de5f 100644
--- a/Command/Trust.hs
+++ b/Command/Trust.hs
@@ -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
-
-start :: [String] -> CommandStart
-start ws = do
- let name = unwords ws
- showStart "trust" name
- u <- Remote.nameToUUID name
- next $ perform u
+seek = trustCommand "trust" Trusted
-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