initremote --sameas fully working
And using sameas remotes is working. Moved annex-config-uuid setting out of Remote.Helper.Special. EnableRemote will also have to set it.
This commit is contained in:
parent
c0e88b7695
commit
35d7ffe128
3 changed files with 20 additions and 16 deletions
|
@ -11,12 +11,15 @@ import qualified Data.Map as M
|
||||||
|
|
||||||
import Command
|
import Command
|
||||||
import Annex.SpecialRemote
|
import Annex.SpecialRemote
|
||||||
|
import Annex.SpecialRemote.Config
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
import qualified Logs.Remote
|
import qualified Logs.Remote
|
||||||
import qualified Types.Remote as R
|
import qualified Types.Remote as R
|
||||||
|
import Annex.UUID
|
||||||
import Logs.UUID
|
import Logs.UUID
|
||||||
import Logs.Remote
|
import Logs.Remote
|
||||||
import Types.GitConfig
|
import Types.GitConfig
|
||||||
|
import Config
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = command "initremote" SectionSetup
|
cmd = command "initremote" SectionSetup
|
||||||
|
@ -63,24 +66,31 @@ start o (name:ws) = ifM (isJust <$> findExisting name)
|
||||||
<$> readRemoteLog
|
<$> readRemoteLog
|
||||||
t <- either giveup return (findType c)
|
t <- either giveup return (findType c)
|
||||||
starting "initremote" (ActionItemOther (Just name)) $
|
starting "initremote" (ActionItemOther (Just name)) $
|
||||||
perform t name c
|
perform t name c o
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
perform :: RemoteType -> String -> R.RemoteConfig -> CommandPerform
|
perform :: RemoteType -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandPerform
|
||||||
perform t name c = do
|
perform t name c o = do
|
||||||
dummycfg <- liftIO dummyRemoteGitConfig
|
dummycfg <- liftIO dummyRemoteGitConfig
|
||||||
(c', u) <- R.setup t R.Init cu Nothing c dummycfg
|
(c', u) <- R.setup t R.Init (sameasu <|> uuidfromuser) Nothing c dummycfg
|
||||||
next $ cleanup u name c'
|
next $ cleanup u name c' o
|
||||||
where
|
where
|
||||||
cu = case M.lookup "uuid" c of
|
uuidfromuser = case M.lookup "uuid" c of
|
||||||
Just s
|
Just s
|
||||||
| isUUID s -> Just (toUUID s)
|
| isUUID s -> Just (toUUID s)
|
||||||
| otherwise -> giveup "invalid uuid"
|
| otherwise -> giveup "invalid uuid"
|
||||||
Nothing -> Nothing
|
Nothing -> Nothing
|
||||||
|
sameasu = toUUID <$> M.lookup sameasUUIDField c
|
||||||
|
|
||||||
cleanup :: UUID -> String -> R.RemoteConfig -> CommandCleanup
|
cleanup :: UUID -> String -> R.RemoteConfig -> InitRemoteOptions -> CommandCleanup
|
||||||
cleanup u name c = do
|
cleanup u name c o = do
|
||||||
describeUUID u (toUUIDDesc name)
|
case sameas o of
|
||||||
Logs.Remote.configSet u c
|
Nothing -> do
|
||||||
|
describeUUID u (toUUIDDesc name)
|
||||||
|
Logs.Remote.configSet u c
|
||||||
|
Just _ -> do
|
||||||
|
cu <- liftIO genUUID
|
||||||
|
setConfig (remoteConfig c "config-uuid") (fromUUID cu)
|
||||||
|
Logs.Remote.configSet cu c
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -74,9 +74,6 @@ gitConfigSpecialRemote u c cfgs = do
|
||||||
forM_ cfgs $ \(k, v) ->
|
forM_ cfgs $ \(k, v) ->
|
||||||
setConfig (remoteConfig c k) v
|
setConfig (remoteConfig c k) v
|
||||||
storeUUIDIn (remoteConfig c "uuid") u
|
storeUUIDIn (remoteConfig c "uuid") u
|
||||||
case M.lookup sameasUUIDField c of
|
|
||||||
Nothing -> noop
|
|
||||||
Just sameasuuid -> setConfig (remoteConfig c "config-uuid") sameasuuid
|
|
||||||
|
|
||||||
-- RetrievalVerifiableKeysSecure unless overridden by git config.
|
-- RetrievalVerifiableKeysSecure unless overridden by git config.
|
||||||
--
|
--
|
||||||
|
|
|
@ -34,9 +34,6 @@ the remote.log. Eg, "B sameas=A foo=bar ..."
|
||||||
|
|
||||||
Implementation notes:
|
Implementation notes:
|
||||||
|
|
||||||
initremote --sameas ends up with the annex-uuid and the annex-config-uuid
|
|
||||||
configured backwards. Oops.
|
|
||||||
|
|
||||||
Need to get enableremote working for sameas.
|
Need to get enableremote working for sameas.
|
||||||
|
|
||||||
Deal with the per-remote state issue.
|
Deal with the per-remote state issue.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue