Skip to content

Commit

Permalink
erepo: fix relative urls for remotes (iterative#2756)
Browse files Browse the repository at this point in the history
  • Loading branch information
tizoc committed Feb 21, 2020
1 parent e4bf5c1 commit 48b646b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions dvc/external_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,23 @@ def _set_cache_dir(self):
self.cache.local.cache_dir = cache_dir

def _set_upstream(self):
# check if the URL is local and no default remote is present
# add default remote pointing to the original repo's cache location
# check if the URL is local and:
# - if no default remote is present, then add default remote
# pointing to the original repo's cache location
# - if a default remote is present, make the URL
# relative to the original repo
if os.path.isdir(self.url):
if not self.config["core"].get("remote"):
src_repo = Repo(self.url)
src_repo = Repo(self.url)
remote_name = self.config["core"].get("remote")
if remote_name:
remote_cfg = self.config["remote"][remote_name]
old_remote_url = src_repo.config["remote"][remote_name]["url"]
if remote_cfg["url"] != old_remote_url:
remote_cfg["url"] = os.path.join(
src_repo.root_dir, old_remote_url
)
src_repo.close()
else:
try:
cache_dir = src_repo.cache.local.cache_dir
finally:
Expand Down

0 comments on commit 48b646b

Please sign in to comment.