Skip to content

Commit

Permalink
BF: dereference relative path while checking for bare from the origin…
Browse files Browse the repository at this point in the history
…al repo path not curdir

Closes datalad#7469
  • Loading branch information
yarikoptic committed Aug 9, 2023
1 parent 74494d4 commit 6b22ad9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions datalad/core/distributed/clone_ephemeral.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion datalad/core/distributed/tests/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 6b22ad9

Please sign in to comment.