scm: Remove usage of distutil

The package is deprecated and will be removed in py 3.12.

R=ddoman@google.com

Bug: 1500415
Change-Id: Ia130c556ad3f2135fac4a9b1d9bb4ecc088cfe9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5030818
Reviewed-by: Scott Lee <ddoman@chromium.org>
Reviewed-by: Jonathan Nieder <jrn@google.com>
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Commit-Queue: Jonathan Nieder <jrn@google.com>
changes/18/5030818/8
Josip Sokcevic 1 year ago committed by LUCI CQ
parent 8fb358e5b6
commit 4cf6518959

@ -628,8 +628,6 @@ class GitWrapper(SCMWrapper):
raise gclient_utils.Error("Unsupported argument(s): %s" %
",".join(args))
self._CheckMinVersion("1.6.6")
url, deps_revision = gclient_utils.SplitUrlRevision(self.url)
revision = deps_revision
managed = True
@ -1385,13 +1383,6 @@ class GitWrapper(SCMWrapper):
# whitespace between projects when syncing.
self.Print('')
@staticmethod
def _CheckMinVersion(min_version):
(ok, current_version) = scm.GIT.AssertVersion(min_version)
if not ok:
raise gclient_utils.Error('git version %s < minimum required %s' %
(current_version, min_version))
def _EnsureValidHeadObjectOrCheckout(self, revision, options, url):
# Special case handling if all 3 conditions are met:
# * the mirros have recently changed, but deps destination remains same,

@ -3,7 +3,6 @@
# found in the LICENSE file.
"""SCM-specific utility classes."""
import distutils.version
import glob
import io
import os
@ -489,14 +488,3 @@ class GIT(object):
if sha_only:
return sha == rev.lower()
return True
@classmethod
def AssertVersion(cls, min_version):
"""Asserts git's version is at least min_version."""
if cls.current_version is None:
current_version = cls.Capture(['--version'], '.')
matched = re.search(r'git version (.+)', current_version)
cls.current_version = distutils.version.LooseVersion(
matched.group(1))
min_version = distutils.version.LooseVersion(min_version)
return (min_version <= cls.current_version, cls.current_version)

@ -635,7 +635,6 @@ class ManagedGitWrapperTestCaseMock(unittest.TestCase):
self.backup_base_path = os.path.join(self.root_dir,
'old_%s.git' % self.relpath)
mock.patch('gclient_scm.scm.GIT.ApplyEnvVars').start()
mock.patch('gclient_scm.GitWrapper._CheckMinVersion').start()
mock.patch('gclient_scm.GitWrapper._Fetch').start()
mock.patch('gclient_scm.GitWrapper._DeleteOrMove').start()
mock.patch('sys.stdout', StringIO()).start()

@ -34,25 +34,6 @@ class GitWrapperTestCase(unittest.TestCase):
mockCapture.assert_called_with(['config', 'user.email'],
cwd=self.root_dir)
@mock.patch('scm.GIT.Capture')
def testAssertVersion(self, mockCapture):
cases = [
('1.7', True),
('1.7.9', True),
('1.7.9.foo-bar-baz', True),
('1.8', True),
('1.6.9', False),
]
for expected_version, expected_ok in cases:
class GIT(scm.GIT):
pass
mockCapture.return_value = 'git version ' + expected_version
ok, version = GIT.AssertVersion('1.7')
self.assertEqual(expected_ok, ok)
self.assertEqual(expected_version, version)
def testRefToRemoteRef(self):
remote = 'origin'
refs = {

Loading…
Cancel
Save