mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
* erepo: fix relative urls for remotes (#2756) * erepo: add test case for relative path remotes (#2756) * Remove unused argument * erepo: move handling of relative remotes to a separate method (#2756) * erepo: don't manually build paths on test (#2756) * erepo: refactor handling of missing or relative upstream (#2756) * erepo: move handling of source repo resource to `_fix_upstream` (#2756) * erepo: improve relative remote tests (#2756) - use `tmp_dir` fixture - commit config file changes * erepo: Remove comment (#2756) * erepo: use scm_add to commit too, no need for separate scm.commit call (#2756) * erepo: minor refactoring in `_fix_upstream` (#2756) * erepo: add comment explaining that old relative paths are restored (#2756)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from mock import patch
|
||||
from dvc.compat import fspath
|
||||
@@ -6,6 +7,7 @@ from dvc.compat import fspath
|
||||
from dvc.external_repo import external_repo
|
||||
from dvc.scm.git import Git
|
||||
from dvc.remote import RemoteLOCAL
|
||||
from dvc.utils import relpath
|
||||
|
||||
|
||||
def test_external_repo(erepo_dir):
|
||||
@@ -88,3 +90,32 @@ def test_pull_subdir_file(tmp_dir, erepo_dir):
|
||||
|
||||
assert dest.is_file()
|
||||
assert dest.read_text() == "contents"
|
||||
|
||||
|
||||
def test_relative_remote(erepo_dir, tmp_dir):
|
||||
# these steps reproduce the script on this issue:
|
||||
# https://github.com/iterative/dvc/issues/2756
|
||||
with erepo_dir.chdir():
|
||||
erepo_dir.dvc_gen("file", "contents", commit="create file")
|
||||
|
||||
upstream_dir = tmp_dir
|
||||
upstream_url = relpath(upstream_dir, erepo_dir)
|
||||
with erepo_dir.dvc.config.edit() as conf:
|
||||
conf["remote"]["upstream"] = {"url": upstream_url}
|
||||
conf["core"]["remote"] = "upstream"
|
||||
|
||||
erepo_dir.scm_add(
|
||||
erepo_dir.dvc.config.files["repo"], commit="Update dvc config"
|
||||
)
|
||||
erepo_dir.dvc.push()
|
||||
|
||||
(erepo_dir / "file").unlink()
|
||||
shutil.rmtree(erepo_dir.dvc.cache.local.cache_dir)
|
||||
|
||||
url = fspath(erepo_dir)
|
||||
|
||||
with external_repo(url) as repo:
|
||||
assert os.path.isabs(repo.config["remote"]["upstream"]["url"])
|
||||
assert os.path.isdir(repo.config["remote"]["upstream"]["url"])
|
||||
with repo.open_by_relpath("file") as fd:
|
||||
assert fd.read() == "contents"
|
||||
|
||||
Reference in New Issue
Block a user