Skip to content

Commit

Permalink
tree: resolve deep remote:// urls (#4568)
Browse files Browse the repository at this point in the history
Fixes #4556
  • Loading branch information
efiop authored Sep 14, 2020
1 parent 8b16af9 commit 424396b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dvc/tree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def _get_conf(repo, **kwargs):
remote_conf = repo.config["remote"][name.lower()]
else:
remote_conf = kwargs
return _resolve_remote_refs(repo.config, remote_conf)
return _resolve_remote_refs(repo, remote_conf)


def _resolve_remote_refs(config, remote_conf):
def _resolve_remote_refs(repo, remote_conf):
# Support for cross referenced remotes.
# This will merge the settings, shadowing base ref with remote_conf.
# For example, having:
Expand All @@ -72,7 +72,7 @@ def _resolve_remote_refs(config, remote_conf):
if parsed.scheme != "remote":
return remote_conf

base = config["remote"][parsed.netloc]
base = _get_conf(repo, name=parsed.netloc)
url = posixpath.join(base["url"], parsed.path.lstrip("/"))
return {**base, **remote_conf, "url": url}

Expand Down
18 changes: 18 additions & 0 deletions tests/unit/tree/test_tree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from dvc.path_info import CloudURLInfo
from dvc.tree import get_cloud_tree


def test_get_cloud_tree(tmp_dir, dvc):
tmp_dir.add_remote(name="base", url="s3://bucket/path", default=False)
tmp_dir.add_remote(name="first", url="remote://base/first", default=False)
tmp_dir.add_remote(
name="second", url="remote://first/second", default=False
)

base = CloudURLInfo("s3://bucket/path")
first = base / "first"
second = first / "second"

assert get_cloud_tree(dvc, name="base").path_info == base
assert get_cloud_tree(dvc, name="first").path_info == first
assert get_cloud_tree(dvc, name="second").path_info == second

0 comments on commit 424396b

Please sign in to comment.