diff options
author | 2015-08-05 13:49:54 -0400 | |
---|---|---|
committer | 2015-08-05 13:49:58 -0400 | |
commit | a43686b9847c19efebd1f15519083436ac155a8e (patch) | |
tree | 98abed3386788da3002142a1053cdce09789c023 /Command | |
parent | 0ad42412dbc981969e0847b498701e6b9ca6dd17 (diff) |
Simplify setup process for a ssh remote.
Now it suffices to run git remote add, followed by git-annex sync. Now the
remote is automatically initialized for use by git-annex, where before the
git-annex branch had to manually be pushed before using git-annex sync.
Note that this involved changes to git-annex-shell, so if the remote is
using an old version, the manual push is still needed.
Implementation required git-annex-shell be changed, so configlist can
autoinit a repository even when no git-annex branch has been pushed yet.
Unfortunate because we'll have to wait for it to get deployed to servers
before being able to rely on this change in the documentation.
Did consider making git-annex sync push the git-annex branch to repos that
didn't have a uuid, but this seemed difficult to do without complicating it
in messy ways.
It would be cleaner to split a command out from configlist to handle
the initialization. But this is difficult without sacrificing backwards
compatability, for users of old git-annex versions which would not use the
new command.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/ConfigList.hs | 8 | ||||
-rw-r--r-- | Command/Sync.hs | 17 |
2 files changed, 16 insertions, 9 deletions
diff --git a/Command/ConfigList.hs b/Command/ConfigList.hs index 95498ba20..e65d0f033 100644 --- a/Command/ConfigList.hs +++ b/Command/ConfigList.hs @@ -14,9 +14,10 @@ import Annex.Init import qualified Annex.Branch import qualified Git.Config import Remote.GCrypt (coreGCryptId) +import qualified CmdLine.GitAnnexShell.Fields as Fields cmd :: Command -cmd = noCommit $ +cmd = noCommit $ dontCheck repoExists $ command "configlist" SectionPlumbing "outputs relevant git configuration" paramNothing (withParams seek) @@ -34,13 +35,14 @@ start = do showConfig k v = liftIO $ putStrLn $ k ++ "=" ++ v {- The repository may not yet have a UUID; automatically initialize it - - when there's a git-annex branch available. -} + - when there's a git-annex branch available or if the autoinit field was + - set. -} findOrGenUUID :: Annex UUID findOrGenUUID = do u <- getUUID if u /= NoUUID then return u - else ifM Annex.Branch.hasSibling + else ifM (Annex.Branch.hasSibling <||> (isJust <$> Fields.getField Fields.autoInit)) ( do initialize Nothing getUUID diff --git a/Command/Sync.hs b/Command/Sync.hs index 3411c9405..9a2417568 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -137,19 +137,24 @@ remoteBranch :: Remote -> Git.Ref -> Git.Ref remoteBranch remote = Git.Ref.underBase $ "refs/remotes/" ++ Remote.name remote syncRemotes :: [String] -> Annex [Remote] -syncRemotes rs = ifM (Annex.getState Annex.fast) ( nub <$> pickfast , wanted ) +syncRemotes ps = do + -- Get remote list first, doing automatic initialization + -- of remotes when possible. + syncRemotes' ps =<< Remote.remoteList' True + +syncRemotes' :: [String] -> [Remote] -> Annex [Remote] +syncRemotes' ps remotelist = ifM (Annex.getState Annex.fast) ( nub <$> pickfast , wanted ) where - pickfast = (++) <$> listed <*> (filterM good =<< fastest <$> available) + pickfast = (++) <$> listed <*> (filterM good (fastest available)) wanted - | null rs = filterM good =<< concat . Remote.byCost <$> available + | null ps = filterM good (concat $ Remote.byCost available) | otherwise = listed - listed = concat <$> mapM Remote.byNameOrGroup rs + listed = concat <$> mapM Remote.byNameOrGroup ps available = filter (remoteAnnexSync . Remote.gitconfig) - . filter (not . Remote.isXMPPRemote) - <$> Remote.remoteList + $ filter (not . Remote.isXMPPRemote) remotelist good r | Remote.gitSyncableRemote r = Remote.Git.repoAvail $ Remote.repo r |