git-annex/Command/Whereis.hs

47 lines
1.2 KiB
Haskell
Raw Normal View History

{- git-annex command
-
- Copyright 2010 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Whereis where
import Control.Monad
import LocationLog
import Command
import Messages
import Remote
import Types
import Trust
command :: [Command]
2011-09-15 18:33:37 +00:00
command = [repoCommand "whereis" paramPaths seek
"lists repositories that have file content"]
seek :: [CommandSeek]
seek = [withFilesInGit start]
start :: FilePath -> CommandStart
start file = isAnnexed file $ \(key, _) -> do
showStart "whereis" file
2011-05-15 06:02:46 +00:00
next $ perform key
perform :: Key -> CommandPerform
perform key = do
2011-09-14 19:33:21 +00:00
(untrustedlocations, safelocations) <- trustPartition UnTrusted =<< keyLocations key
let num = length safelocations
2011-03-05 21:41:36 +00:00
showNote $ show num ++ " " ++ copiesplural num
pp <- prettyPrintUUIDs "whereis" safelocations
unless (null safelocations) $
showLongNote pp
pp' <- prettyPrintUUIDs "untrusted" untrustedlocations
unless (null untrustedlocations) $
showLongNote $ untrustedheader ++ pp'
if null safelocations then stop else next $ return True
2011-03-05 21:41:36 +00:00
where
copiesplural 1 = "copy"
copiesplural _ = "copies"
untrustedheader = "The following untrusted locations may also have copies:\n"