Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Deduplicate component names on verbosity 0
Browse files Browse the repository at this point in the history
since on verbosity 0 only product version and component name shows,
griffon showed a lot of duplicities, eg. one product version had
3 product streams, and each stream had the component and thus component
showed 3 times with the same product version as product streams are not
shown on verbosity level 0
  • Loading branch information
JakubFrejlach committed Feb 12, 2024
1 parent 327c4d7 commit 07a1a93
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions griffon/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ def rhel_br_deduplicate(result_tree: dict) -> dict:
"""
if component exists for both rhel-X and rhel-br-X
product version and product stream keep only the rhel-X record
"""
filtered_result_tree = result_tree
for pv in list(result_tree.keys()):
Expand Down Expand Up @@ -510,6 +509,7 @@ def text_output_products_contain_component(
else:
if ctx.obj["VERBOSE"] == 0: # product_version X root component nvr
for pv in result_tree.keys():
used_component_names = set() # store used component names for deduplication
for ps in result_tree[pv].keys():
for cn in sorted(result_tree[pv][ps].keys()):
# select the latest nvr (from sorted list)
Expand All @@ -533,7 +533,7 @@ def text_output_products_contain_component(
dep = f"[{root_component_color}]{dep_name}[/{root_component_color}]" # noqa
if result_tree[pv][ps][cn][nvr]["upstreams"]:
upstream_component_names = sorted(
list(
set(
[
f"{upstream['name']}"
for upstream in result_tree[pv][ps][cn][nvr][
Expand All @@ -542,6 +542,15 @@ def text_output_products_contain_component(
]
)
)

# deduplicate upstream component names
upstream_component_names = sorted(
set(upstream_component_names) - used_component_names
)
used_component_names = used_component_names.union(
set(upstream_component_names)
)

for upstream_component_name in upstream_component_names:
console.print(
Text(pv, style=f"{product_color} b"),
Expand All @@ -561,15 +570,28 @@ def text_output_products_contain_component(
)
)
)

# deduplicate source component names
source_component_names = sorted(
set(source_component_names) - used_component_names
)
used_component_names = used_component_names.union(
set(source_component_names)
)

for source_component_name in source_component_names:
console.print(
Text(pv, style=f"{product_color} b"),
f"[pale_turquoise1]{source_component_name}[/pale_turquoise1]", # noqa
no_wrap=no_wrap,
)
if not (result_tree[pv][ps][cn][nvr]["upstreams"]) and not (
result_tree[pv][ps][cn][nvr]["sources"]
if (
not (result_tree[pv][ps][cn][nvr]["upstreams"])
and not (result_tree[pv][ps][cn][nvr]["sources"])
and dep_name
not in used_component_names # deduplicate single component name
):
used_component_names.add(dep_name)
console.print(
Text(pv, style=f"{product_color} b"),
dep,
Expand Down

0 comments on commit 07a1a93

Please sign in to comment.