diff options
author | Joey Hess <joeyh@joeyh.name> | 2014-12-29 13:41:03 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2014-12-29 13:42:58 -0400 |
commit | 9315d96f700109da18f953534b0b5bab8d1440dd (patch) | |
tree | 62aa269152a1be8cab550fcff7732c29c9d6ad64 /Remote.hs | |
parent | 17efa06748ddf67c0bc29359cedba381e7db4625 (diff) |
sync: Now supports remote groups, the same way git remote update does.
Diffstat (limited to 'Remote.hs')
-rw-r--r-- | Remote.hs | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -26,6 +26,7 @@ module Remote ( uuidDescriptions, byName, byName', + byNameOrGroup, byNameOnly, byNameWithUUID, byCost, @@ -94,7 +95,11 @@ addName desc n | otherwise = desc ++ " [" ++ n ++ "]" {- When a name is specified, looks up the remote matching that name. - - (Or it can be a UUID.) -} + - (Or it can be a UUID.) + - + - Throws an error if a name is specified and no matching remote can be + - found. + -} byName :: Maybe RemoteName -> Annex (Maybe Remote) byName Nothing = return Nothing byName (Just n) = either error Just <$> byName' n @@ -121,6 +126,14 @@ byName' n = go . filter matching <$> remoteList go (match:_) = Right match matching r = n == name r || toUUID n == uuid r +{- Finds the remote or remote group matching the name. -} +byNameOrGroup :: RemoteName -> Annex [Remote] +byNameOrGroup n = go =<< getConfigMaybe (ConfigKey ("remotes." ++ n)) + where + go (Just l) = concatMap maybeToList <$> + mapM (Remote.byName . Just) (split " " l) + go Nothing = maybeToList <$> Remote.byName (Just n) + {- Only matches remote name, not UUID -} byNameOnly :: RemoteName -> Annex (Maybe Remote) byNameOnly n = headMaybe . filter matching <$> remoteList |