Skip to content

Commit

Permalink
ENH: gitrepo: Declare and check minimum Git version
Browse files Browse the repository at this point in the history
We do not specify a minimum supported Git version, which makes it
difficult for us to decide whether we can use a newer feature and
means that users have to rely on trial and error to know whether their
version is recent enough.

Set a minimum Git version, handling it in a way that closely follows
what AnnexRepo already does for the minimum git-annex version.  Choose
2.19.1 (September 2018) as the minimum because that (1) matches what
conda currently has for its 32-bit Linux builds [0] and (2) is below
what is currently in Debian stable (v2.20.1).

Note that if we decide to lower the minimum more, the hard floor
should probably be considered v2.13.0 (May 2017).  As described a few
commits back, AnnexRepo._check_files() doesn't work reliably until
then and testing with v2.13.0 didn't reveal major problems [1], though
the skips added in the two previous commits were needed.

[0] #4636 (comment)
[1] https://travis-ci.org/github/datalad/datalad/builds/701067382

Closes #4636.
  • Loading branch information
kyleam committed Jun 22, 2020
1 parent 8db852a commit ff042b8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions datalad/support/gitrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,9 @@ class GitRepo(RepoInterface, metaclass=PathBasedFlyweight):

_unique_instances = WeakValueDictionary()

GIT_MIN_VERSION = "2.19.1"
git_version = None

def _flyweight_invalid(self):
return not self.is_valid_git()

Expand All @@ -820,6 +823,11 @@ def __hash__(self):
# add the class name to distinguish from strings of a path
return hash((self.__class__.__name__, self.__weakref__.key))

@classmethod
def _check_git_version(cls):
external_versions.check("cmd:git", min_version=cls.GIT_MIN_VERSION)
cls.git_version = external_versions['cmd:git']

# This is the least common denominator to claim that a user
# used DataLad.
# For now citing Zenodo's all (i.e., latest) version
Expand Down Expand Up @@ -876,6 +884,8 @@ def __init__(self, path, url=None, runner=None, create=True,
C='/my/path' => -C /my/path
"""
if self.git_version is None:
self._check_git_version()

# BEGIN Repo validity test
# We want to fail early for tests, that would be performed a lot. In particular this is about
Expand Down

0 comments on commit ff042b8

Please sign in to comment.