From 6b22ad9250504ad4ddb93ba1825424388d79915e Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 8 Aug 2023 23:22:29 -0400 Subject: [PATCH] BF: dereference relative path while checking for bare from the original repo path not curdir Closes #7469 --- datalad/core/distributed/clone_ephemeral.py | 4 ++++ datalad/core/distributed/tests/test_clone.py | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/datalad/core/distributed/clone_ephemeral.py b/datalad/core/distributed/clone_ephemeral.py index 02082e9274..1c13382754 100644 --- a/datalad/core/distributed/clone_ephemeral.py +++ b/datalad/core/distributed/clone_ephemeral.py @@ -92,6 +92,10 @@ def _setup_ephemeral_annex(ds: Dataset, remote: str): # If origin isn't local, we have nothing to do. origin_git_path = Path(RI(origin_annex_url).localpath) + if not origin_git_path.is_absolute(): + # relative path would be relative to the ds, not pwd! + origin_git_path = ds.pathobj / origin_git_path + # we are local; check for a bare repo first to not mess w/ # the path if GitRepo(origin_git_path, create=False).bare: diff --git a/datalad/core/distributed/tests/test_clone.py b/datalad/core/distributed/tests/test_clone.py index ce60d4eb32..d5fd1b7efe 100644 --- a/datalad/core/distributed/tests/test_clone.py +++ b/datalad/core/distributed/tests/test_clone.py @@ -1365,8 +1365,10 @@ def test_ria_http_storedataladorg(path=None): @with_tempfile @with_tempfile @with_tempfile +@with_tempfile def test_ephemeral(origin_path=None, bare_path=None, - clone1_path=None, clone2_path=None, clone3_path=None): + clone1_path=None, clone2_path=None, + clone3_path=None, clone4_path=None): can_symlink = has_symlink_capability() file_test = Path('ds') / 'test.txt' @@ -1450,6 +1452,12 @@ def check_clone(clone_): ok_(eph_annex.is_symlink()) ok_(eph_annex.resolve().samefile(Path(bare_path) / 'annex')) + # 5. ephemeral clone using relative path + # https://github.com/datalad/datalad/issues/7469 + with chpwd(op.dirname(origin_path)): + clone4 = clone(op.basename(origin_path), op.basename(clone4_path), reckless='ephemeral') + check_clone(clone4) + @with_tempfile(mkdir=True) def test_clone_unborn_head(path=None):