Avoid using regex at all

This commit is contained in:
Felix Yan 2020-09-24 05:45:09 +08:00
parent d7624defd7
commit 7213d84056
No known key found for this signature in database
GPG Key ID: 786C63F330D7CB92
1 changed files with 2 additions and 4 deletions

View File

@ -1,7 +1,6 @@
# MIT licensed
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, 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