From 9e073c226e0a6bab6d7d0b2deaa74b6db9f75e6c Mon Sep 17 00:00:00 2001 From: Daniel <33197631+dadav@users.noreply.github.com> Date: Fri, 6 Sep 2024 18:26:53 +0000 Subject: [PATCH] [red-hat-openshift] Fix pattern (#379) The Red Hat people changed the format of the dates AND the format of the versions from this: === RHSA-2024:5808 - {product-title} 4.12.64 bug fix and security update to this === RHSA-2024:0041 - {product-title} {product-version}.0 image release, bug fix, and security update advisory. But not for all branches, but only for the latest (4.16 and up). Fixes #378 --- src/red-hat-openshift.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/red-hat-openshift.py b/src/red-hat-openshift.py index 2bc1d5a9..e6c6629b 100644 --- a/src/red-hat-openshift.py +++ b/src/red-hat-openshift.py @@ -5,7 +5,10 @@ from common.git import Git """Fetches Red Hat OpenShift versions from the documentation's git repository""" -VERSION_AND_DATE_PATTERN = re.compile(r"{product-title}\s(?P\d+\.\d+\.\d+).*\n+Issued:\s(?P\d{4}-\d\d-\d\d)$", re.MULTILINE) +VERSION_AND_DATE_PATTERN = re.compile( + r"{product-title}\s(?P{product-version}\.\d+|\d+\.\d+\.\d+).*\n+Issued:\s(?P\d\d?\s[a-zA-Z]+\s\d{4}|\d{4}-\d\d-\d\d)$", + re.MULTILINE, +) with releasedata.ProductData("red-hat-openshift") as product_data: git = Git("https://github.com/openshift/openshift-docs.git") @@ -13,8 +16,9 @@ with releasedata.ProductData("red-hat-openshift") as product_data: # only fetch v4+ branches, because the format was different in openshift v3 for branch in git.list_branches("refs/heads/enterprise-[4-9]*"): - version = branch.split("-")[1].replace(".", "-") - release_notes_filename = f"release_notes/ocp-{version}-release-notes.adoc" + branch_version = branch.split("-")[1] + file_version = branch_version.replace(".", "-") + release_notes_filename = f"release_notes/ocp-{file_version}-release-notes.adoc" git.checkout(branch, file_list=[release_notes_filename]) release_notes_file = git.repo_dir / release_notes_filename @@ -23,5 +27,8 @@ with releasedata.ProductData("red-hat-openshift") as product_data: with release_notes_file.open("rb") as f: content = f.read().decode("utf-8") - for (version, date_str) in VERSION_AND_DATE_PATTERN.findall(content): - product_data.declare_version(version, dates.parse_date(date_str)) + for version, date_str in VERSION_AND_DATE_PATTERN.findall(content): + product_data.declare_version( + version.replace("{product-version}", branch_version), + dates.parse_date(date_str), + )