get rid of hardcoded "name" lookups

Support "sameas-name" being set instead.

In RenameRemote, rename which ever of the two is set.
This commit is contained in:
Joey Hess 2019-10-10 13:08:17 -04:00
parent 92ff30df70
commit d1130ea04a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
15 changed files with 45 additions and 14 deletions

View file

@ -155,7 +155,7 @@ externalSetup _ mu _ c gc = do
c'' <- case M.lookup "readonly" c of
Just v | isTrue v == Just True -> do
setConfig (remoteConfig (fromJust (M.lookup "name" c)) "readonly") (boolConfig True)
setConfig (remoteConfig (fromJust (lookupName c)) "readonly") (boolConfig True)
return c'
_ -> do
external <- newExternal externaltype u c' gc

View file

@ -183,7 +183,7 @@ unsupportedUrl = giveup "using non-ssh remote repo url with gcrypt is not suppor
gCryptSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID)
gCryptSetup _ mu _ c gc = go $ M.lookup "gitrepo" c
where
remotename = fromJust (M.lookup "name" c)
remotename = fromJust (lookupName c)
go Nothing = giveup "Specify gitrepo="
go (Just gitrepo) = do
(c', _encsetup) <- encryptionSetup c gc

View file

@ -32,6 +32,7 @@ import qualified Annex.Content
import qualified Annex.BranchState
import qualified Annex.Branch
import qualified Annex.Url as Url
import qualified Annex.SpecialRemote.Config as SpecialRemote
import Utility.Tmp
import Config
import Config.Cost
@ -120,7 +121,7 @@ gitSetup (Enable _) (Just u) _ c _ = do
inRepo $ Git.Command.run
[ Param "remote"
, Param "add"
, Param $ fromMaybe (giveup "no name") (M.lookup "name" c)
, Param $ fromMaybe (giveup "no name") (SpecialRemote.lookupName c)
, Param $ fromMaybe (giveup "no location") (M.lookup "location" c)
]
return (c, u)

View file

@ -157,7 +157,7 @@ mySetup _ mu _ c gc = do
return (c'', u)
where
url = fromMaybe (giveup "Specify url=") (M.lookup "url" c)
remotename = fromJust (M.lookup "name" c)
remotename = fromJust (lookupName c)
data LFSHandle = LFSHandle
{ downloadEndpoint :: Maybe LFS.Endpoint

View file

@ -104,7 +104,7 @@ glacierSetup' ss u mcreds c gc = do
gitConfigSpecialRemote u fullconfig [("glacier", "true")]
return (fullconfig, u)
where
remotename = fromJust (M.lookup "name" c)
remotename = fromJust (lookupName c)
defvault = remotename ++ "-" ++ fromUUID u
defaults = M.fromList
[ ("datacenter", T.unpack $ AWS.defaultRegion AWS.Glacier)

View file

@ -30,6 +30,7 @@ module Remote.Helper.Special (
specialRemoteCfg,
specialRemote,
specialRemote',
lookupName,
module X
) where

View file

@ -150,7 +150,7 @@ s3Setup' ss u mcreds c gc
| configIA c = archiveorg
| otherwise = defaulthost
where
remotename = fromJust (M.lookup "name" c)
remotename = fromJust (lookupName c)
defbucket = remotename ++ "-" ++ fromUUID u
defaults = M.fromList
[ ("datacenter", T.unpack $ AWS.defaultRegion AWS.S3)