Skip to content

Commit 555854f

Browse files
authored
Merge pull request #1100 from shifa-khan/list-overrides-1079
feat(list-overrides): show per-package min_release_age in --details output
2 parents 06e6317 + cf3e16d commit 555854f

4 files changed

Lines changed: 67 additions & 2 deletions

File tree

src/fromager/commands/list_overrides.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ def list_overrides(
111111
[v for v in all_patches.keys() if v is not None]
112112
)
113113

114+
min_release_age = ps.resolver_dist.min_release_age
115+
min_release_age_str = (
116+
str(min_release_age) if min_release_age is not None else ""
117+
)
118+
114119
if not all_pkg_versions:
115120
# This package has overrides, but none are version-specific.
116121
patches_str = str(num_global_patches) if num_global_patches else ""
@@ -119,6 +124,7 @@ def list_overrides(
119124
"version": "",
120125
"patches": patches_str,
121126
"plugin_hooks": plugin_hooks_str,
127+
"min_release_age": min_release_age_str,
122128
}
123129
# Add variant information
124130
row_data.update(variant_info)
@@ -135,6 +141,7 @@ def list_overrides(
135141
"version": str(version),
136142
"patches": patches_str,
137143
"plugin_hooks": plugin_hooks_str,
144+
"min_release_age": min_release_age_str,
138145
}
139146
# Add variant information
140147
row_data.update(variant_info)
@@ -166,7 +173,11 @@ def _export_csv(
166173
) -> None:
167174
"""Export data as CSV."""
168175
# Define field names in the order we want them
169-
fieldnames = ["package", "version", "patches"] + variants + ["plugin_hooks"]
176+
fieldnames = (
177+
["package", "version", "patches", "min_release_age"]
178+
+ variants
179+
+ ["plugin_hooks"]
180+
)
170181

171182
if output:
172183
with open(output, "w", newline="") as outfile:
@@ -190,13 +201,19 @@ def _export_table(data: list[dict], variants: list[str]) -> None:
190201
table.add_column("Version", justify="left", no_wrap=True)
191202
table.add_column("Patches", justify="left", no_wrap=True)
192203

204+
table.add_column("Min Release Age (days)", justify="left", no_wrap=True)
205+
193206
for v in variants:
194207
table.add_column(v, justify="left", no_wrap=True)
195208

196209
table.add_column("Plugin", justify="left")
197210

198211
# Define column keys in the same order as CSV exporter
199-
column_keys = ["package", "version", "patches"] + variants + ["plugin_hooks"]
212+
column_keys = (
213+
["package", "version", "patches", "min_release_age"]
214+
+ variants
215+
+ ["plugin_hooks"]
216+
)
200217

201218
for row_data in data:
202219
row = [row_data.get(key, "") for key in column_keys]

tests/test_list_overrides.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def test_list_overrides_details_table(
7070
assert "test-other-pkg" in result.stdout
7171
assert "test-pkg" in result.stdout
7272
assert "test-pkg-library" in result.stdout
73+
assert "Min Release Age (days)" in result.stdout
7374

7475

7576
def test_list_overrides_details_json(
@@ -112,6 +113,7 @@ def test_list_overrides_details_json(
112113
assert "version" in first_item
113114
assert "patches" in first_item
114115
assert "plugin_hooks" in first_item
116+
assert "min_release_age" in first_item
115117
assert "rocm" in first_item # variant column
116118

117119

@@ -148,6 +150,7 @@ def test_list_overrides_details_csv(
148150
assert '"version"' in header
149151
assert '"patches"' in header
150152
assert '"plugin_hooks"' in header
153+
assert '"min_release_age"' in header
151154
assert '"rocm"' in header # variant column
152155

153156
# Check data rows
@@ -251,3 +254,43 @@ def test_list_overrides_warnings_without_details(
251254
in result.output
252255
)
253256
assert "test-other-pkg" in result.output
257+
258+
259+
def test_list_overrides_min_release_age(
260+
testdata_path: pathlib.Path, cli_runner: CliRunner
261+
) -> None:
262+
"""Test that min_release_age per-package override appears in --details output."""
263+
overrides_dir = testdata_path / "context" / "overrides"
264+
settings_file = overrides_dir / "settings.yaml"
265+
settings_dir = overrides_dir / "settings"
266+
patches_dir = overrides_dir / "patches"
267+
268+
result = cli_runner.invoke(
269+
fromager,
270+
[
271+
"--settings-file",
272+
str(settings_file),
273+
"--settings-dir",
274+
str(settings_dir),
275+
"--patches-dir",
276+
str(patches_dir),
277+
"list-overrides",
278+
"--details",
279+
"--format",
280+
"json",
281+
],
282+
)
283+
assert result.exit_code == 0
284+
285+
json_output = _extract_json_from_output(result.stdout)
286+
data = json.loads(json_output)
287+
288+
# test-cooldown-pkg has resolver_dist.min_release_age: 7 in its settings YAML
289+
test_cooldown_pkg = next(
290+
item for item in data if item["package"] == "test-cooldown-pkg"
291+
)
292+
assert test_cooldown_pkg["min_release_age"] == "7"
293+
294+
# test-other-pkg has no min_release_age override — should be empty
295+
test_other_pkg = next(item for item in data if item["package"] == "test-other-pkg")
296+
assert test_other_pkg["min_release_age"] == ""

tests/test_packagesettings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
TEST_OTHER_PKG = "test-other-pkg"
3030
TEST_RELATED_PKG = "test-pkg-library"
3131
TEST_PREBUILT_PKG = "test-prebuilt-pkg"
32+
TEST_COOLDOWN_PKG = "test-cooldown-pkg"
3233

3334
FULL_EXPECTED: dict[str, typing.Any] = {
3435
"annotations": {
@@ -507,6 +508,7 @@ def test_settings_overrides(testdata_context: context.WorkContext) -> None:
507508
TEST_OTHER_PKG,
508509
TEST_RELATED_PKG,
509510
TEST_PREBUILT_PKG,
511+
TEST_COOLDOWN_PKG,
510512
}
511513

512514

@@ -552,6 +554,7 @@ def test_global_changelog(testdata_context: context.WorkContext) -> None:
552554

553555
def test_settings_list(testdata_context: context.WorkContext) -> None:
554556
assert testdata_context.settings.list_overrides() == {
557+
TEST_COOLDOWN_PKG,
555558
TEST_EMPTY_PKG,
556559
TEST_OTHER_PKG,
557560
TEST_PKG,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
resolver_dist:
2+
min_release_age: 7

0 commit comments

Comments
 (0)