Update ambiguous oid parsing to detect candidates on Git 2.31+ (#4897)

* Update ambiguous oid parsing to detect candidates on Git 2.31+

* Update tests
This commit is contained in:
jack1142
2021-03-24 00:52:52 +01:00
committed by GitHub
parent e5ffe86c4e
commit ef803072fa
3 changed files with 78 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ from redbot.cogs.downloader.repo_manager import RepoManager, Repo, ProcessFormat
from redbot.cogs.downloader.installable import Installable, InstalledModule
__all__ = [
"GIT_VERSION",
"repo_manager",
"repo",
"bot_repo",
@@ -27,6 +28,17 @@ __all__ = [
]
def _get_git_version():
"""Returns version tuple in format: (major, minor)"""
raw_version = sp.check_output(("git", "version"), text=True)[12:]
# we're only interested in major and minor version if we will ever need micro
# there's more handling needed for versions like `2.25.0-rc1` and `2.25.0.windows.1`
return tuple(int(n) for n in raw_version.split(".", maxsplit=3)[:2])
GIT_VERSION = _get_git_version()
async def fake_run_noprint(*args, **kwargs):
fake_result_tuple = namedtuple("fake_result", "returncode result")
res = fake_result_tuple(0, (args, kwargs))