Revert "git-cl: Remove unused and duplicate functions."
This reverts commit e3a49aa40576da2427447f7fedb670d5d59216e5.
Reason for revert:
TypeError: expected str, bytes or os.PathLike object, not NoneType
Original change's description:
> git-cl: Remove unused and duplicate functions.
>
> Remove unused functions, and use scm.GIT where possible to reduce
> duplication.
>
> Change-Id: I24f05e7b3ae04743e97b6665ee668f44d6acc294
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116938
> Reviewed-by: Anthony Polito <apolito@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
TBR=ehmaldonado@chromium.org,apolito@google.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com,sokcevic@google.com
Change-Id: I334a6289eb2c1f3e20feddd428307542d2aa38a9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2119411
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/scm.py b/scm.py
index aa65dac..eb413a2 100644
--- a/scm.py
+++ b/scm.py
@@ -4,7 +4,6 @@
"""SCM-specific utility classes."""
-import distutils.version
import glob
import io
import os
@@ -114,8 +113,8 @@
def Capture(args, cwd, strip_out=True, **kwargs):
env = GIT.ApplyEnvVars(kwargs)
output = subprocess2.check_output(
- ['git'] + args, cwd=cwd, stderr=subprocess2.PIPE, env=env, **kwargs)
- output = output.decode('utf-8', 'replace')
+ ['git'] + args, cwd=cwd, stderr=subprocess2.PIPE, env=env,
+ **kwargs).decode('utf-8', 'replace')
return output.strip() if strip_out else output
@staticmethod
@@ -407,7 +406,13 @@
"""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)
+ matched = re.search(r'version ([0-9\.]+)', current_version)
+ cls.current_version = matched.group(1)
+ current_version_list = list(map(only_int, cls.current_version.split('.')))
+ for min_ver in map(int, min_version.split('.')):
+ ver = current_version_list.pop(0)
+ if ver < min_ver:
+ return (False, cls.current_version)
+ elif ver > min_ver:
+ return (True, cls.current_version)
+ return (True, cls.current_version)