diff options
author | 2010-12-28 17:44:55 -0400 | |
---|---|---|
committer | 2010-12-28 17:44:55 -0400 | |
commit | 1f20277ec7f23fa638422987d312f02f6ae1a5ee (patch) | |
tree | 7b8e1ece390a29c8029118aa3118779bb8012cee /Command | |
parent | 3714364905a23f3b64c6573a4121bd1cc5acb11e (diff) |
forgot to add these
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Trust.hs | 40 | ||||
-rw-r--r-- | Command/Untrust.hs | 40 |
2 files changed, 80 insertions, 0 deletions
diff --git a/Command/Trust.hs b/Command/Trust.hs new file mode 100644 index 000000000..8060ee66f --- /dev/null +++ b/Command/Trust.hs @@ -0,0 +1,40 @@ +{- git-annex command + - + - Copyright 2010 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.Trust where + +import Control.Monad.State (liftIO) +import Control.Monad (unless) + +import Command +import qualified Annex +import qualified GitRepo as Git +import qualified Remotes +import UUID +import Messages + +seek :: [SubCmdSeek] +seek = [withString start] + +{- Marks a remote as trusted. -} +start :: SubCmdStartString +start name = do + r <- Remotes.byName name + showStart "trust" name + return $ Just $ perform r + +perform :: Git.Repo -> SubCmdPerform +perform repo = do + uuid <- getUUID repo + trusted <- getTrusted + unless (elem uuid trusted) $ do + setTrusted $ uuid:trusted + g <- Annex.gitRepo + logfile <- trustLog + liftIO $ Git.run g ["add", logfile] + liftIO $ Git.run g ["commit", "-m", "git annex untrust", logfile] + return $ Just $ return True diff --git a/Command/Untrust.hs b/Command/Untrust.hs new file mode 100644 index 000000000..5ed8de245 --- /dev/null +++ b/Command/Untrust.hs @@ -0,0 +1,40 @@ +{- git-annex command + - + - Copyright 2010 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.Untrust where + +import Control.Monad.State (liftIO) +import Control.Monad (when) + +import Command +import qualified Annex +import qualified GitRepo as Git +import qualified Remotes +import UUID +import Messages + +seek :: [SubCmdSeek] +seek = [withString start] + +{- Marks a remote as not trusted. -} +start :: SubCmdStartString +start name = do + r <- Remotes.byName name + showStart "untrust" name + return $ Just $ perform r + +perform :: Git.Repo -> SubCmdPerform +perform repo = do + uuid <- getUUID repo + trusted <- getTrusted + when (elem uuid trusted) $ do + setTrusted $ filter (\u -> u /= uuid) trusted + g <- Annex.gitRepo + logfile <- trustLog + liftIO $ Git.run g ["add", logfile] + liftIO $ Git.run g ["commit", "-m", "git annex untrust", logfile] + return $ Just $ return True |