From 7213d84056642c62976c5a54bf8b6ad706b192ee Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Thu, 24 Sep 2020 05:45:09 +0800 Subject: [PATCH] Avoid using regex at all --- nvchecker_source/git.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nvchecker_source/git.py b/nvchecker_source/git.py index 14459a7..89e0b6d 100644 --- a/nvchecker_source/git.py +++ b/nvchecker_source/git.py @@ -1,7 +1,6 @@ # MIT licensed # Copyright (c) 2020 Felix Yan , et al. -import re from .cmd import run_cmd # type: ignore async def get_version( @@ -10,6 +9,5 @@ async def get_version( git = conf['git'] cmd = f"git ls-remote -t --refs {git}" data = await cache.get(cmd, run_cmd) - regex = "(?<=refs/tags/).*$" - - return re.findall(regex, data, re.MULTILINE) + versions = list(map(lambda line: line.split("refs/tags/")[1], data.split("\n"))) + return versions