diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-02-07 14:35:58 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-02-07 14:55:58 -0400 |
commit | dc0f824c1bc4c9aac1045894983a434eb26196ab (patch) | |
tree | a84543bd5ea46c8655fdd189f148f8bab9e48664 /Remote/Git.hs | |
parent | 2d5e728c407f5d3447365211a64b088700834787 (diff) |
add SetupStage parameter to RemoteType.setup
Most remotes have an idempotent setup that can be reused for
enableremote, but in a few cases, it needs to tell which, and whether
a UUID was provided to setup was used.
This is groundwork for making initremote be able to provide a UUID.
It should not change any behavior.
Note that it would be nice to make the UUID always be provided to setup,
and make setup not need to generate and return a UUID. What prevented
this simplification is Remote.Git.gitSetup, which needs to reuse the
UUID of the git remote when setting it up, and so has to return that
UUID.
This commit was sponsored by Thom May on Patreon.
Diffstat (limited to 'Remote/Git.hs')
-rw-r--r-- | Remote/Git.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs index 5eb6fbc9e..a0b590654 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -96,8 +96,8 @@ list autoinit = do - No attempt is made to make the remote be accessible via ssh key setup, - etc. -} -gitSetup :: Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID) -gitSetup Nothing _ c _ = do +gitSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID) +gitSetup Init mu _ c _ = do let location = fromMaybe (giveup "Specify location=url") $ Url.parseURIRelaxed =<< M.lookup "location" c g <- Annex.gitRepo @@ -105,8 +105,10 @@ gitSetup Nothing _ c _ = do [r] -> getRepoUUID r [] -> giveup "could not find existing git remote with specified location" _ -> giveup "found multiple git remotes with specified location" - return (c, u) -gitSetup (Just u) _ c _ = do + if isNothing mu || mu == Just u + then return (c, u) + else error "git remote did not have specified uuid" +gitSetup Enable (Just u) _ c _ = do inRepo $ Git.Command.run [ Param "remote" , Param "add" @@ -114,6 +116,7 @@ gitSetup (Just u) _ c _ = do , Param $ fromMaybe (giveup "no location") (M.lookup "location" c) ] return (c, u) +gitSetup Enable Nothing _ _ _ = error "unable to enable git remote with no specified uuid" {- It's assumed to be cheap to read the config of non-URL remotes, so this is - done each time git-annex is run in a way that uses remotes. |