Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions scripts/release-notes/gen_gh_releases_from_rhocp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,25 @@ def get_rpm_releases():
# Disable all repos (in the memory, not on the host) to just query RHOCP repos and make operation faster.
base.repos.all().disable()

# Enable RHOCP repos starting from 4.14 to the current-2 (inclusive; range() stops before the second argument).
# Enable RHOCP repos starting from 4.14 up to current-2 (inclusive).
# E.g., for 4.21 it's 4.14-4.19 because when 4.21 development started, the 4.20 wasn't released yet.
# For major version 5, start from 5.0; for major version 4, start from 4.14.
# The -2 gap spans across major boundaries: versions form a linear sequence
# (4.14, ..., 4.22, 5.0, 5.1, ...) and current-1 is handled by the try block below.
repo_versions = []
if int(current_major) >= 5:
for m in range(14, common.LAST_MINOR_FOR_MAJOR[4] + 1):
repo_versions.append(("4", m))
start_minor = 0 if int(current_major) >= 5 else 14
for minor in range(start_minor, int(current_minor)-1):
repo_id = f"rhocp-{current_major}.{minor}-for-rhel-9-{arch}-rpms"
r = base.repos.get_matching(repo_id)
for m in range(start_minor, int(current_minor)):
repo_versions.append((current_major, m))
repo_versions = repo_versions[:-1]
Comment on lines +42 to +48

@coderabbitai coderabbitai Bot May 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

This repo walk still hardcodes the 4→5 transition.

If current_major ever becomes 6, this builds 4.14..4.x plus 6.0..6.(n-2) and skips every 5.x repo, so release discovery will silently miss a full major. Please derive the sequence from common.get_previous_version() (or iterate all majors via common.LAST_MINOR_FOR_MAJOR) instead of hardcoding common.LAST_MINOR_FOR_MAJOR[4].

Possible fix
-        repo_versions = []
-        if int(current_major) >= 5:
-            for m in range(14, common.LAST_MINOR_FOR_MAJOR[4] + 1):
-                repo_versions.append(("4", m))
-        start_minor = 0 if int(current_major) >= 5 else 14
-        for m in range(start_minor, int(current_minor)):
-            repo_versions.append((current_major, m))
-        repo_versions = repo_versions[:-1]
+        repo_versions_backwards = []
+        major, minor = current_major, current_minor
+        while (int(major), int(minor)) != (4, 14):
+            major, minor = common.get_previous_version(major, minor)
+            repo_versions_backwards.append((major, int(minor)))
+        repo_versions = list(reversed(repo_versions_backwards[1:]))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/release-notes/gen_gh_releases_from_rhocp.py` around lines 42 - 48,
The loop building repo_versions hardcodes the 4→5 transition and will skip
entire majors when current_major > 5; update the logic in
gen_gh_releases_from_rhocp.py to derive the prior-major sequence dynamically
(use common.get_previous_version() or iterate keys of
common.LAST_MINOR_FOR_MAJOR) instead of referencing
common.LAST_MINOR_FOR_MAJOR[4]; specifically, replace the special-case block
that checks if int(current_major) >= 5 and appends ("4", m) with a loop that
walks backwards through majors from current_major down to the earliest major,
using LAST_MINOR_FOR_MAJOR[major] for each major’s last minor and appending
(str(major-1), m) or equivalent so repo_versions correctly includes every minor
for every intervening major, and ensure repo_versions trimming (repo_versions =
repo_versions[:-1]) still behaves as intended.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to worry about this just yet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, @pmtk! Would you like me to open a follow-up GitHub issue to track the generalization for future major versions (e.g., 6.x)?


logging.info(f"Based on provided version {current_major}.{current_minor} calculated versions: {', '.join(f'{t[0]}.{t[1]}' for t in repo_versions)}")
for major, minor in repo_versions:
repo_id = f"rhocp-{major}.{minor}-for-rhel-9-{arch}-rpms"
r = base.repos.get(repo_id)
r.enable()
logging.info(f'Enabled repo: {r.id} - {r.name}')
logging.info(f'Enabled repo: {repo_id}')

# It's faster to enable bunch of repos at once and fill the sack once rather than filling it after enabling each repo.
base.fill_sack()
Expand Down