Skip to content

Commit 96c5729

Browse files
committed
bugs: flush and query before opening editor
Resolves: #204 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 8b4b877 commit 96c5729

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/pkgdev/scripts/pkgdev_bugs.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,11 +700,12 @@ def merge_stabilization_groups(self, out: Formatter, err: Formatter) -> bool:
700700
self.merge_nodes(mergable)
701701
return True
702702

703-
def scan_existing_bugs(self, api_key: str):
703+
def scan_existing_bugs(self, api_key: str) -> bool:
704704
# Paginate the search request with batches of 100 items to avoid HTTP 414 errors
705705
all_packages = list({pkg[0].unversioned_atom for node in self.nodes for pkg in node.pkgs})
706706
batch_size = 100
707707
all_bugs = []
708+
has_output = False
708709

709710
for i in range(0, len(all_packages), batch_size):
710711
params = urlencode(
@@ -747,7 +748,9 @@ def scan_existing_bugs(self, api_key: str):
747748
self.out.reset,
748749
)
749750
self.out.write(" -> bug summary: ", bug["summary"])
751+
has_output = True
750752
break
753+
return has_output
751754

752755
def file_bugs(self, api_key: str, auto_cc_arches: frozenset[str], block_bugs: list[int]):
753756
def observe(node: GraphNode):
@@ -795,8 +798,11 @@ def main(options, out: Formatter, err: Formatter):
795798
out.write(out.fg("red"), "Nothing to do, exiting", out.reset)
796799
return 1
797800

801+
has_output = False
798802
if userquery("Check for open bugs matching current graph?", out, err, default_answer=False):
799-
d.scan_existing_bugs(options.api_key)
803+
if d.scan_existing_bugs(options.api_key):
804+
out.flush()
805+
has_output = True
800806

801807
if not d.merge_stabilization_groups(out, err):
802808
out.write(out.fg("red"), "Aborted", out.reset)
@@ -814,8 +820,13 @@ def main(options, out: Formatter, err: Formatter):
814820
d.output_dot(options.dot)
815821
out.write(out.fg("green"), f"Dot file written to {options.dot}", out.reset)
816822
out.flush()
823+
has_output = True
817824

818825
if options.edit_graph:
826+
if has_output and not userquery("Ready to open editor?", out, err, default_answer=True):
827+
out.write(out.fg("red"), "Aborted", out.reset)
828+
return 1
829+
819830
editor = shlex.split(os.environ.get("VISUAL", os.environ.get("EDITOR", "nano")))
820831
try:
821832
subprocess.run(editor + [toml.name], check=True)

0 commit comments

Comments
 (0)