Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No GitPython #4172

Merged
merged 10 commits into from Mar 6, 2020
16 changes: 4 additions & 12 deletions .travis.yml
Expand Up @@ -100,22 +100,15 @@ matrix:
- python: 3.5
# Test some under NFS mount (only selected sub-set)
env:
# do not run SSH-based tests due to stall(s)
# https://github.com/datalad/datalad/pull/4172
- DATALAD_TESTS_SSH=0
- TMPDIR="/tmp/nfsmount"
- TESTS_TO_PERFORM="datalad.tests datalad.support"
#
# The ones to run only on weekends against master.
# They will not contribute to coverage etc, but might lead to failed status
#
- python: 3.5
# By default no logs will be output. This one is to test with log output at INFO level
env:
- _DL_UPSTREAM_GITPYTHON=1
# It is not usable without setting locales env vars ATM
# see https://github.com/datalad/datalad/issues/3159
# - _DL_UPSTREAM_GITANNEX=1
# Just so we test if we did not screw up running under nose without -s as well
- NOSE_OPTS=
- _DL_CRON=1
# run if git-annex version in neurodebian -devel differs
- python: 3.5
env:
Expand Down Expand Up @@ -206,7 +199,6 @@ before_install:
# Install grunt-cli
- eatmydata npm install grunt-cli
# Install optionally upstream current development so we are sure that they break nothing important for us
- if [ ! -z "${_DL_UPSTREAM_GITPYTHON:-}" ]; then pip install https://github.com/gitpython-developers/GitPython/archive/master.zip; fi
- if [ ! -z "${_DL_UPSTREAM_GITANNEX:-}" ]; then sudo tools/ci/install-annex-snapshot.sh; sudo ln -s `find /usr/local/lib/git-annex.linux -maxdepth 1 -type f -perm /+x` /usr/local/bin/; else sudo eatmydata apt-get install git-annex-standalone ; fi
# Install optionally -devel version of annex, and if goes wrong (we have most recent), exit right away
- if [ ! -z "${_DL_DEVEL_ANNEX:-}" ]; then tools/ci/prep-travis-devel-annex.sh || { ex="$?"; if [ "$ex" -eq 99 ]; then exit 0; else exit "$ex"; fi; }; fi
Expand All @@ -232,7 +224,7 @@ install:
# TMPDIRs
- if [[ "${TMPDIR:-}" =~ .*/sym\ link ]]; then echo "Symlinking $TMPDIR"; ln -s /tmp "$TMPDIR"; fi
- if [[ "${TMPDIR:-}" =~ .*/d\ i\ r ]]; then echo "mkdir $TMPDIR"; mkdir -p "$TMPDIR"; fi
- if [[ "${TMPDIR:-}" =~ .*/nfsmount ]]; then echo "mkdir $TMPDIR"; mkdir -p "$TMPDIR" "${TMPDIR}_"; echo "/tmp/nfsmount_ localhost(rw)" | sudo bash -c 'cat - > /etc/exports'; sudo apt-get install -y nfs-kernel-server; sudo exportfs -a; sudo mount -t nfs localhost:/tmp/nfsmount_ /tmp/nfsmount; fi
- if [[ "${TMPDIR:-}" =~ .*/nfsmount ]]; then echo "mkdir $TMPDIR"; mkdir -p "$TMPDIR" "${TMPDIR}_"; echo "/tmp/nfsmount_ localhost(rw)" | sudo bash -c 'cat - > /etc/exports'; sudo apt-get install -y nfs-kernel-server; sudo exportfs -a; sudo mount -t nfs localhost:/tmp/nfsmount_ /tmp/nfsmount; sudo git config --system annex.pidlock true ; fi
# S3
- if [ ! -z "$UNSET_S3_SECRETS" ]; then echo "usetting"; unset DATALAD_datalad_test_s3_key_id DATALAD_datalad_test_s3_secret_id; fi
# Install grunt to test run javascript frontend tests
Expand Down
17 changes: 9 additions & 8 deletions datalad/__init__.py
Expand Up @@ -43,14 +43,6 @@
# Other imports are interspersed with lgr.debug to ease troubleshooting startup
# delays etc.

# If there is a bundled git, make sure GitPython uses it too:
from datalad.cmd import GitRunner
GitRunner._check_git_path()
if GitRunner._GIT_PATH:
import os
os.environ['GIT_PYTHON_GIT_EXECUTABLE'] = \
os.path.join(GitRunner._GIT_PATH, 'git')

from .config import ConfigManager
cfg = ConfigManager()

Expand Down Expand Up @@ -130,6 +122,15 @@ def setup_package():
""")
_TEMP_PATHS_GENERATED.append(new_home)

# If there is a bundled git, make sure GitPython uses it too
# (some parts of the test utilities still rely on GitPython)
from datalad.cmd import GitRunner
GitRunner._check_git_path()
if GitRunner._GIT_PATH:
import os
os.environ['GIT_PYTHON_GIT_EXECUTABLE'] = \
os.path.join(GitRunner._GIT_PATH, 'git')

# Re-load ConfigManager, since otherwise it won't consider global config
# from new $HOME (see gh-4153
cfg.reload(force=True)
Expand Down
2 changes: 1 addition & 1 deletion datalad/auto.py
Expand Up @@ -23,7 +23,7 @@
from os.path import exists
from os.path import isabs
from os.path import join as opj
from git.exc import InvalidGitRepositoryError
from datalad.support.exceptions import InvalidGitRepositoryError

from .utils import getpwd
from .dochelpers import exc_str
Expand Down
2 changes: 1 addition & 1 deletion datalad/cmdline/helpers.py
Expand Up @@ -212,7 +212,7 @@ def get_repo_instance(path=curdir, class_=None):
"""

from os.path import ismount, exists, normpath, isabs
from git.exc import InvalidGitRepositoryError
from datalad.support.exceptions import InvalidGitRepositoryError
from ..utils import expandpath
from ..support.gitrepo import GitRepo
from ..support.annexrepo import AnnexRepo
Expand Down
10 changes: 6 additions & 4 deletions datalad/distribution/dataset.py
Expand Up @@ -29,15 +29,17 @@
# DueCredit
from datalad.support.due import due
from datalad.support.due_utils import duecredit_dataset
from datalad.support.exceptions import NoDatasetArgumentFound
from datalad.support.exceptions import (
InvalidAnnexRepositoryError,
InvalidGitRepositoryError,
NoDatasetArgumentFound,
NoSuchPathError,
)
from datalad.support.gitrepo import (
GitRepo,
InvalidGitRepositoryError,
NoSuchPathError
)
from datalad.support.repo import PathBasedFlyweight
from datalad.support.network import RI
from datalad.support.exceptions import InvalidAnnexRepositoryError
from datalad.support import path as op

import datalad.utils as ut
Expand Down
2 changes: 0 additions & 2 deletions datalad/distribution/publish.py
Expand Up @@ -15,8 +15,6 @@
from collections import OrderedDict
from os.path import join as opj

from git.remote import PushInfo as PI

from datalad import ssh_manager
from datalad.interface.annotate_paths import AnnotatePaths
from datalad.interface.annotate_paths import annotated2content_by_ds
Expand Down
4 changes: 2 additions & 2 deletions datalad/distribution/tests/test_create_sibling.py
Expand Up @@ -33,13 +33,13 @@
assert_not_equal,
assert_not_in,
assert_raises,
assert_repo_status,
assert_result_count,
assert_status,
create_tree,
eq_,
get_mtimes_and_digests,
ok_,
ok_clean_git,
ok_endswith,
ok_exists,
ok_file_has_content,
Expand Down Expand Up @@ -440,7 +440,7 @@ def check_target_ssh_since(use_ssh, origin, src_path, target_path):
# get a new subdataset and make sure it is committed in the super
source.create('brandnew')
eq_(len(source.subdatasets()), 3)
ok_clean_git(source.path)
assert_repo_status(source.path)

# and now we create a sibling for the new subdataset only
assert_create_sshwebserver(
Expand Down
10 changes: 5 additions & 5 deletions datalad/distribution/tests/test_create_test_dataset.py
Expand Up @@ -15,8 +15,8 @@
from datalad.tests.utils import (
with_tempfile,
assert_raises,
assert_repo_status,
ok_,
ok_clean_git,
known_failure_githubci_win,
)
from datalad.utils import (
Expand Down Expand Up @@ -49,7 +49,7 @@ def test_create_test_dataset():
dss = create_test_dataset(spec='2/1-2')
ok_(5 <= len(dss) <= 7) # at least five - 1 top, two on top level, 1 in each
for ds in dss:
ok_clean_git(ds, annex=None) # some of them are annex but we just don't check
assert_repo_status(ds, annex=None) # some of them are annex but we just don't check
ok_(len(glob(opj(ds, 'file*'))))


Expand All @@ -59,7 +59,7 @@ def test_create_1test_dataset():
with swallow_outputs():
dss = create_test_dataset()
eq_(len(dss), 1)
ok_clean_git(dss[0], annex=False)
assert_repo_status(dss[0], annex=False)


@with_tempfile(mkdir=True)
Expand All @@ -70,7 +70,7 @@ def test_new_relpath(topdir):
eq_(dss[0], opj(topdir, 'testds'))
eq_(len(dss), 2) # 1 top + 1 sub-dataset as demanded
for ds in dss:
ok_clean_git(ds, annex=False)
assert_repo_status(ds, annex=False)


@known_failure_githubci_win
Expand All @@ -84,7 +84,7 @@ def test_hierarchy(topdir):
eq_(len(dss), 3)
eq_(dss[0], topdir)
for ids, ds in enumerate(dss):
ok_clean_git(ds, annex=False)
assert_repo_status(ds, annex=False)
# each one should have 2 commits (but the last one)-- one for file and
# another one for sub-dataset
repo = GitRepo(ds)
Expand Down
6 changes: 3 additions & 3 deletions datalad/distribution/tests/test_dataset.py
Expand Up @@ -48,13 +48,13 @@
assert_is_not_none,
assert_not_equal,
assert_raises,
assert_repo_status,
assert_result_count,
assert_true,
eq_,
known_failure_windows,
OBSCURE_FILENAME,
ok_,
ok_clean_git,
SkipTest,
with_tempfile,
with_testrepos,
Expand Down Expand Up @@ -385,7 +385,7 @@ def test_property_reevaluation(repo1):
assert_is_none(ds.id)

ds.create()
ok_clean_git(repo1)
assert_repo_status(repo1)
# after creation, we have `repo`, and `config` was reevaluated to point
# to the repo's config:
assert_is_not_none(ds.repo)
Expand All @@ -409,7 +409,7 @@ def test_property_reevaluation(repo1):
assert_is_none(ds.id)

ds.create()
ok_clean_git(repo1)
assert_repo_status(repo1)
# after recreation everything is sane again:
assert_is_not_none(ds.repo)
assert_is_not_none(ds.config)
Expand Down
4 changes: 2 additions & 2 deletions datalad/distribution/tests/test_get.py
Expand Up @@ -30,7 +30,6 @@
)
from datalad.tests.utils import (
ok_,
ok_clean_git,
eq_,
with_tempfile,
with_testrepos,
Expand All @@ -41,6 +40,7 @@
assert_status,
assert_in_results,
assert_not_in_results,
assert_repo_status,
assert_result_count,
assert_message,
serve_path_via_http,
Expand Down Expand Up @@ -334,7 +334,7 @@ def test_get_recurse_subdatasets(src, path):
ok_(subds1.repo.file_has_content('test-annex.dat') is False)
ok_(subds2.repo.file_has_content('test-annex.dat') is False)

ok_clean_git(subds1.path)
assert_repo_status(subds1.path)
# explicitly given path in subdataset => implicit recursion:
# MIH: Nope, we fulfill the dataset handle, but that doesn't
# imply fulfilling all file handles
Expand Down