Skip to content

Commit

Permalink
TST: annexrepo: Update test for "no commits" sub-repo fix in Git
Browse files Browse the repository at this point in the history
As of Git 2.22.0, specifically b22827045e (dir: do not traverse
repositories with no commits, 2019-04-09), 'git ls-files' now treats a
repository on an unborn branch as a repository rather than a
directory.

Fixes datalad#3490.
  • Loading branch information
kyleam committed Jun 26, 2019
1 parent fbd3fc9 commit ff2bc90
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions datalad/support/tests/test_annexrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1989,28 +1989,50 @@ def sync_wrapper(push=False, pull=False, commit=False):

# create a subrepo:
sub = AnnexRepo(opj(ar.path, 'submod'), create=True)
# nothing changed, it's empty besides .git, which is ignored
eq_(stat, ar.get_status())

# file in subrepo
with open(opj(ar.path, 'submod', 'fourth'), 'w') as f:
f.write("this is a birth certificate")
stat['untracked'].append(opj('submod', 'fourth'))
eq_(stat, ar.get_status())
# ATTN: We look at the bundle git rather than "cmd:git" because `git annex
# status` will use it regardless of DATALAD_USE_DEFAULT_GIT.
bundled = external_versions['cmd:bundled-git']
if bundled is external_versions.UNKNOWN:
git_version = external_versions['cmd:git']
else:
git_version = bundled
if git_version >= '2.22.0':
# Newer Git versions consider a repo without a commit a repository, not
# a directory.
stat["untracked"].append("submod/")
eq_(stat, ar.get_status())

# add to subrepo
sub.add('fourth')
sub.commit(msg="birther mod init'ed")
stat['untracked'].remove(opj('submod', 'fourth'))
# Nothing changes, since the empty repo is still seen as a repo.
with open(opj(ar.path, 'submod', 'fourth'), 'w') as f:
f.write("this is a birth certificate")
eq_(stat, ar.get_status())

if ar.get_active_branch().endswith('(unlocked)') and \
'adjusted' in ar.get_active_branch():
# we are running on adjusted branch => do it in submodule, too
sub.adjust()
sub.add('fourth')
sub.commit(msg="birther mod init'ed")
else:
# nothing changed, it's empty besides .git, which is ignored
eq_(stat, ar.get_status())

# Note, that now the non-empty repo is untracked
stat['untracked'].append('submod/')
eq_(stat, ar.get_status())
# file in subrepo
with open(opj(ar.path, 'submod', 'fourth'), 'w') as f:
f.write("this is a birth certificate")
stat['untracked'].append(opj('submod', 'fourth'))
eq_(stat, ar.get_status())

# add to subrepo
sub.add('fourth')
sub.commit(msg="birther mod init'ed")
stat['untracked'].remove(opj('submod', 'fourth'))

if ar.get_active_branch().endswith('(unlocked)') and \
'adjusted' in ar.get_active_branch():
# we are running on adjusted branch => do it in submodule, too
sub.adjust()

# Note, that now the non-empty repo is untracked
stat['untracked'].append('submod/')
eq_(stat, ar.get_status())

# add the submodule
ar.add_submodule('submod', url=opj(curdir, 'submod'))
Expand Down

0 comments on commit ff2bc90

Please sign in to comment.