Align custom scripts with generic scripts (#445)
Align custom scripts with generic scripts, making them configurable. This has a few advantages: - script code is more unified, - no more hard-coded method names in scripts, which is less error prone and make it easier to rename scripts, - no more hard coded product names in scripts, which is less error prone and make it easier to rename products, - less hard-coded URLs and regexes in scripts, which makes auto-configuration more expressive / updatable, Also added method `endoflife.list_configs_from_argv()` so that it is easier to manipulate scripts arguments.
This commit is contained in:
@@ -1,34 +1,24 @@
|
||||
import re
|
||||
|
||||
from common import dates, releasedata
|
||||
from common import dates, endoflife, releasedata
|
||||
from common.git import Git
|
||||
|
||||
"""Fetches Apache HTTP Server versions and release date from its git repository
|
||||
by looking at the STATUS file of each <major>.<minor>.x branch."""
|
||||
|
||||
VERSION_AND_DATE_PATTERNS = [
|
||||
# for most versions
|
||||
re.compile(r"\s+(?P<version>\d+\.\d+\.\d+)\s*:.*(?:Released|Announced|Released and Retired)\s(?:on\s)?(?P<date>\w+\s\d\d?,\s\d{4})"),
|
||||
# for older 2.0.x versions (only GA versions are considered)
|
||||
re.compile(r"\s+(?P<version>\d+\.\d+\.\d+)\s*:.*released\s(?P<date>\w+\s\d\d?,\s\d{4}) as GA"),
|
||||
# for older 1.3.x versions, we take the date of the tag and not the date of the release (too difficult to parse)
|
||||
re.compile(r"\s+(?P<version>\d+\.\d+\.\d+)\s*:.*Tagged and [rR]olled\s(?:on\s)?(?P<date>\w+\.?\s\d\d?,\s\d{4})"),
|
||||
]
|
||||
for config in endoflife.list_configs_from_argv():
|
||||
with releasedata.ProductData(config.product) as product_data:
|
||||
git = Git(config.url)
|
||||
git.setup()
|
||||
|
||||
with releasedata.ProductData("apache-http-server") as product_data:
|
||||
git = Git("https://github.com/apache/httpd.git")
|
||||
git.setup()
|
||||
for branch in git.list_branches("refs/heads/?.?.x"):
|
||||
git.checkout(branch, file_list=["STATUS"])
|
||||
|
||||
for branch in git.list_branches("refs/heads/?.?.x"):
|
||||
git.checkout(branch, file_list=["STATUS"])
|
||||
release_notes_file = git.repo_dir / "STATUS"
|
||||
if not release_notes_file.exists():
|
||||
continue
|
||||
|
||||
release_notes_file = git.repo_dir / "STATUS"
|
||||
if not release_notes_file.exists():
|
||||
continue
|
||||
with release_notes_file.open("rb") as f:
|
||||
release_notes = f.read().decode("utf-8", errors="ignore")
|
||||
|
||||
with release_notes_file.open("rb") as f:
|
||||
release_notes = f.read().decode("utf-8", errors="ignore")
|
||||
|
||||
for pattern in VERSION_AND_DATE_PATTERNS:
|
||||
for (version, date_str) in pattern.findall(release_notes):
|
||||
product_data.declare_version(version, dates.parse_date(date_str))
|
||||
for pattern in config.include_version_patterns:
|
||||
for (version, date_str) in pattern.findall(release_notes):
|
||||
product_data.declare_version(version, dates.parse_date(date_str))
|
||||
|
||||
Reference in New Issue
Block a user