export remoteList

This commit is contained in:
Joey Hess 2011-12-30 19:10:54 -04:00
parent f6f7ee7131
commit dba8fc8a1c

View file

@ -16,6 +16,7 @@ module Remote (
hasKeyCheap, hasKeyCheap,
remoteTypes, remoteTypes,
remoteList,
remoteMap, remoteMap,
byName, byName,
prettyPrintUUIDs, prettyPrintUUIDs,
@ -65,8 +66,8 @@ remoteTypes =
{- Builds a list of all available Remotes. {- Builds a list of all available Remotes.
- Since doing so can be expensive, the list is cached. -} - Since doing so can be expensive, the list is cached. -}
genList :: Annex [Remote Annex] remoteList :: Annex [Remote Annex]
genList = do remoteList = do
rs <- Annex.getState Annex.remotes rs <- Annex.getState Annex.remotes
if null rs if null rs
then do then do
@ -86,7 +87,7 @@ genList = do
{- Map of UUIDs of Remotes and their names. -} {- Map of UUIDs of Remotes and their names. -}
remoteMap :: Annex (M.Map UUID String) remoteMap :: Annex (M.Map UUID String)
remoteMap = M.fromList . map (\r -> (uuid r, name r)) <$> genList remoteMap = M.fromList . map (\r -> (uuid r, name r)) <$> remoteList
{- Looks up a remote by name. (Or by UUID.) Only finds currently configured {- Looks up a remote by name. (Or by UUID.) Only finds currently configured
- git remotes. -} - git remotes. -}
@ -99,8 +100,7 @@ byName n = do
byName' :: String -> Annex (Either String (Remote Annex)) byName' :: String -> Annex (Either String (Remote Annex))
byName' "" = return $ Left "no remote specified" byName' "" = return $ Left "no remote specified"
byName' n = do byName' n = do
allremotes <- genList match <- filter matching <$> remoteList
let match = filter matching allremotes
if null match if null match
then return $ Left $ "there is no git remote named \"" ++ n ++ "\"" then return $ Left $ "there is no git remote named \"" ++ n ++ "\""
else return $ Right $ Prelude.head match else return $ Right $ Prelude.head match
@ -196,7 +196,7 @@ keyPossibilities' withtrusted key = do
let validtrusteduuids = validuuids `intersect` trusted let validtrusteduuids = validuuids `intersect` trusted
-- remotes that match uuids that have the key -- remotes that match uuids that have the key
allremotes <- filterM (repoNotIgnored . repo) =<< genList allremotes <- filterM (repoNotIgnored . repo) =<< remoteList
let validremotes = remotesWithUUID allremotes validuuids let validremotes = remotesWithUUID allremotes validuuids
return (sort validremotes, validtrusteduuids) return (sort validremotes, validtrusteduuids)