diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2011-12-29 20:50:57 +0100 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2011-12-29 20:50:57 +0100 |
commit | b6e7b40be4721595bafd3b1ea9c439cead07b7ff (patch) | |
tree | ff2c6295854a592ce48d3b761d297ef92ef0828f /Command | |
parent | 0ee1141f30b188e5ef52125c163ff2cf80c661ee (diff) |
By default, sync with all remotes having the synced/ branch
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Sync.hs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs index a9089463d..cc8818889 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE BangPatterns #-} {- git-annex command - - Copyright 2011 Joey Hess <joey@kitenet.net> @@ -26,10 +27,10 @@ def = [command "sync" (paramOptional (paramRepeating paramRemote)) -- syncing involves several operations, any of which can independantly fail seek :: CommandSeek seek args = do + !branch <- currentBranch remotes <- if null args - then defaultSyncRemotes + then defaultSyncRemotes branch else mapM Remote.byName args - branch <- currentBranch showStart "syncing" $ "branch " ++ Git.Ref.describe branch ++ " with remote repositories " ++ intercalate "," (map Remote.name remotes) showOutput return $ @@ -42,8 +43,16 @@ seek args = do [ pushLocal branch ] ++ [ pushRemote remote branch | remote <- remotes ] -defaultSyncRemotes :: Annex [Remote.Remote Annex] -defaultSyncRemotes = undefined +defaultSyncRemotes :: Git.Ref -> Annex [Remote.Remote Annex] +defaultSyncRemotes branch = mapM Remote.byName =<< process . L.unpack <$> inRepo showref + where + syncbranch = Git.Ref $ "refs/heads/synced/" ++ Git.Ref.describe branch + showref = Git.Command.pipeRead + [Param "show-ref", Param (Git.Ref.describe syncbranch)] + process = map getRemoteName . filter isRemote . map getBranchName . lines + isRemote r = "refs/remotes/" `isPrefixOf` r + getBranchName = snd . separate (== ' ') + getRemoteName = fst . separate (== '/') . snd . separate (== '/') . snd . separate (== '/') commit :: CommandStart commit = do |