Use a default regex when possible (#205)

This commit is contained in:
Marc Wrobel
2023-12-01 21:08:11 +01:00
parent e97e261946
commit 750faaa64f
10 changed files with 20 additions and 35 deletions

View File

@@ -13,14 +13,6 @@ do not support partial clone so we cannot.
"""
METHOD = 'cgit'
# Same as used in Ruby (update.rb)
DEFAULT_TAG_TEMPLATE = (
"{{major}}{% if minor %}.{{minor}}{% if patch %}.{{patch}}{%if tiny %}.{{tiny}}{%endif%}{%endif%}{%endif%}"
)
DEFAULT_VERSION_REGEX = (
r"^v?(?P<major>\d+)\.(?P<minor>\d+)\.?(?P<patch>\d+)?\.?(?P<tiny>\d+)?$"
)
def make_bs_request(url):
response = endoflife.fetch_url(url + '/refs/tags')
@@ -56,8 +48,8 @@ def update_product(product_name, configs):
versions = {}
for config in configs:
t = config.get("template", DEFAULT_TAG_TEMPLATE)
regex = config.get("regex", DEFAULT_VERSION_REGEX)
t = config.get("template", endoflife.DEFAULT_TAG_TEMPLATE)
regex = config.get("regex", endoflife.DEFAULT_VERSION_REGEX)
versions = versions | fetch_releases(config[METHOD], regex, t)
endoflife.write_releases(product_name, versions)