Skip to content

Commit 8b4b877

Browse files
committed
bugs: confirm with user when only partial stabilization group
In cases where only some of the packages in a stabilization group are present in the graph, it's likely that the user forgot to call it with the full `@group` format. But, there are also cases where this is intentional (e.g. when the user only wants to stablize a revbump), so ask the user to confirm. Resolves: #211 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 8864062 commit 8b4b877

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/pkgdev/scripts/pkgdev_bugs.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,8 @@ def merge_new_keywords_children(self):
675675
found_someone = True
676676
break
677677

678-
def merge_stabilization_groups(self):
678+
def merge_stabilization_groups(self, out: Formatter, err: Formatter) -> bool:
679+
all_pkgs = {pkg.unversioned_atom for node in self.nodes for pkg, _ in node.pkgs}
679680
for group, pkgs in self.options.repo.stabilization_groups.items():
680681
restrict = packages.OrRestriction(*pkgs)
681682
mergable = tuple(
@@ -684,8 +685,20 @@ def merge_stabilization_groups(self):
684685
if node.bugno is None and any(restrict.match(pkg) for pkg, _ in node.pkgs)
685686
)
686687
if mergable:
688+
if missing_pkgs := pkgs - all_pkgs:
689+
self.out.write(
690+
self.out.fg("yellow"),
691+
f"Detected {len(missing_pkgs)} missing packages in @{group} group\n",
692+
"\n".join(f" - {pkg}" for pkg in sorted(missing_pkgs)),
693+
self.out.reset,
694+
)
695+
if not userquery(
696+
" Confirm this was intentional?", out, err, default_answer=False
697+
):
698+
return False
687699
self.out.write(f"Merging @{group} group nodes: {mergable}")
688700
self.merge_nodes(mergable)
701+
return True
689702

690703
def scan_existing_bugs(self, api_key: str):
691704
# Paginate the search request with batches of 100 items to avoid HTTP 414 errors
@@ -785,7 +798,9 @@ def main(options, out: Formatter, err: Formatter):
785798
if userquery("Check for open bugs matching current graph?", out, err, default_answer=False):
786799
d.scan_existing_bugs(options.api_key)
787800

788-
d.merge_stabilization_groups()
801+
if not d.merge_stabilization_groups(out, err):
802+
out.write(out.fg("red"), "Aborted", out.reset)
803+
return 1
789804
d.merge_cycles()
790805
d.merge_new_keywords_children()
791806

0 commit comments

Comments
 (0)