proxied remotes working on client side
Got the right git config settings inherited now. Note that the url config is not passed on to git, so it won't be able to access the proxied remote. That would need some kind of git-remote-annex but for proxied remotes anyway. Unsure yet if that will be needed.
This commit is contained in:
parent
5aaa285083
commit
4b940c92bb
1 changed files with 38 additions and 26 deletions
|
@ -1,6 +1,6 @@
|
||||||
{- Standard git remotes.
|
{- Standard git remotes.
|
||||||
-
|
-
|
||||||
- Copyright 2011-2023 Joey Hess <id@joeyh.name>
|
- Copyright 2011-2024 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -789,51 +789,63 @@ listProxied proxies rs = concat <$> mapM go rs
|
||||||
u <- getRepoUUID r
|
u <- getRepoUUID r
|
||||||
gc <- Annex.getRemoteGitConfig r
|
gc <- Annex.getRemoteGitConfig r
|
||||||
let cu = fromMaybe u $ remoteAnnexConfigUUID gc
|
let cu = fromMaybe u $ remoteAnnexConfigUUID gc
|
||||||
pure $ if not (canproxy gc r) || cu ==NoUUID
|
if not (canproxy gc r) || cu ==NoUUID
|
||||||
then []
|
then pure []
|
||||||
else case M.lookup cu proxies of
|
else case M.lookup cu proxies of
|
||||||
Nothing -> []
|
Nothing -> pure []
|
||||||
Just s -> mapMaybe (mkproxied g r) (S.toList s)
|
Just s -> catMaybes
|
||||||
|
<$> mapM (mkproxied g r) (S.toList s)
|
||||||
|
|
||||||
proxyremotename r p = do
|
proxiedremotename r p = do
|
||||||
n <- Git.remoteName r
|
n <- Git.remoteName r
|
||||||
pure $ n ++ "-" ++ proxyRemoteName p
|
pure $ n ++ "-" ++ proxyRemoteName p
|
||||||
|
|
||||||
mkproxied g r p = mkproxied' g r p =<< proxyremotename r p
|
mkproxied g r p = case proxiedremotename r p of
|
||||||
|
Nothing -> pure Nothing
|
||||||
|
Just proxyname -> mkproxied' g r p proxyname
|
||||||
|
|
||||||
|
-- The proxied remote is constructed by renaming the proxy remote,
|
||||||
|
-- and setting the proxied remote's inherited configs, url and
|
||||||
|
-- uuid in Annex state.
|
||||||
mkproxied' g r p proxyname
|
mkproxied' g r p proxyname
|
||||||
| any isconfig (M.keys (Git.config g)) = Nothing
|
| any isconfig (M.keys (Git.config g)) = pure Nothing
|
||||||
-- The proxied remote is constructed by renaming the
|
| otherwise = do
|
||||||
-- proxy remote, changing its uuid, and inheriting some
|
-- Not using addGitConfigOverride for inherited
|
||||||
-- of its config. The url in particular stays the same.
|
-- configs and the uuid, because child git processes
|
||||||
| otherwise = Just $ renamedr
|
-- do not need them to be provided with -c.
|
||||||
{ Git.config = M.map Prelude.head c
|
Annex.adjustGitRepo (pure . configadjuster)
|
||||||
, Git.fullconfig = c
|
return $ Just $ renamedr
|
||||||
}
|
|
||||||
where
|
where
|
||||||
renamedr = r { Git.remoteName = Just proxyname }
|
renamedr = r { Git.remoteName = Just proxyname }
|
||||||
|
|
||||||
c = M.insert
|
configadjuster r' =
|
||||||
|
let c = adduuid $ inheritconfigs $ Git.fullconfig r'
|
||||||
|
in r'
|
||||||
|
{ Git.config = M.map Prelude.head c
|
||||||
|
, Git.fullconfig = c
|
||||||
|
}
|
||||||
|
|
||||||
|
adduuid = M.insert
|
||||||
(configRepoUUID renamedr)
|
(configRepoUUID renamedr)
|
||||||
[Git.ConfigValue $ fromUUID $ proxyRemoteUUID p]
|
[Git.ConfigValue $ fromUUID $ proxyRemoteUUID p]
|
||||||
inheritedconfig
|
|
||||||
|
|
||||||
inheritedconfig = M.fromList $
|
inheritconfigs c = foldl' inheritconfig c proxyInheritedFields
|
||||||
mapMaybe inheritconfig proxyInheritedFields
|
|
||||||
|
|
||||||
inheritconfig k = do
|
inheritconfig c k = case (M.lookup dest c, M.lookup src c) of
|
||||||
let rk = remoteAnnexConfig r k
|
(Nothing, Just v) -> M.insert dest v c
|
||||||
v <- M.lookup rk (Git.fullconfig r)
|
_ -> c
|
||||||
pure $ (rk, v)
|
where
|
||||||
|
src = remoteAnnexConfig r k
|
||||||
|
dest = remoteAnnexConfig renamedr k
|
||||||
|
|
||||||
-- When the git config has anything set for a remote,
|
-- When the git config has anything set for a remote,
|
||||||
-- avoid making a proxied remote with the same name.
|
-- avoid making a proxied remote with the same name.
|
||||||
-- It is possible to set git configs of proxies, but it
|
-- It is possible to set git configs of proxies, but it
|
||||||
-- needs both the url and uuid config to be manually set.
|
-- needs both the url and uuid config to be manually set.
|
||||||
isconfig (Git.ConfigKey configkey) =
|
isconfig (Git.ConfigKey configkey) =
|
||||||
configprefix `B.isPrefixOf` configkey
|
proxyconfigprefix `B.isPrefixOf` configkey
|
||||||
where
|
where
|
||||||
Git.ConfigKey configprefix = remoteConfig proxyname mempty
|
Git.ConfigKey proxyconfigprefix = remoteConfig proxyname mempty
|
||||||
|
|
||||||
-- Git remotes that are gcrypt or git-lfs special remotes cannot
|
-- Git remotes that are gcrypt or git-lfs special remotes cannot
|
||||||
-- proxy. Proxing is also not yet supported for remotes using P2P
|
-- proxy. Proxing is also not yet supported for remotes using P2P
|
||||||
|
|
Loading…
Reference in a new issue