Skip to content

Commit f0b5cb5

Browse files
committed
bugs: offer filing a new bug on a non-exact match
The prompt for a bug matching the package but not the version was a yes/no obsolete question, where declining silently reused the bug. Make the three outcomes explicit: obsolete it, reuse it, or leave it alone and file our own. Resolves: #230 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 104dc15 commit f0b5cb5

3 files changed

Lines changed: 38 additions & 9 deletions

File tree

‎NEWS.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
Release Notes
33
=============
44

5+
pkgdev 0.2.19 (unreleased)
6+
--------------------------
7+
8+
**pkgdev bugs:**
9+
10+
- bugs: a bug matching the package but not the version can now be left alone
11+
while a new bug is filed, alongside obsoleting it or reusing it (Arthur
12+
Zamarin, #230)
13+
514
pkgdev 0.2.18 (2026-09-05)
615
--------------------------
716

‎src/pkgdev/scripts/pkgdev_bugs.py‎

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from functools import partial
1414
from itertools import chain
1515
from os.path import join as pjoin
16+
from typing import Literal
1617

1718
from pkgcheck import const as pkgcheck_const
1819
from pkgcheck.addons import ArchesAddon, init_addon
@@ -1101,6 +1102,19 @@ def merge_stabilization_groups(self, out: Formatter, err: Formatter) -> bool:
11011102
self.merge_nodes(mergable)
11021103
return True
11031104

1105+
def _query_atom_match(self) -> Literal["obsolete", "reuse", "new"]:
1106+
return userquery(
1107+
"Not an exact match. Obsolete it, reuse it, or file a new bug?",
1108+
self.out,
1109+
self.err,
1110+
responses={
1111+
"obsolete": ("obsolete", self.out.fg("red"), "Obsolete"),
1112+
"reuse": ("reuse", self.out.fg("green"), "Reuse"),
1113+
"new": ("new", self.out.fg("yellow"), "New"),
1114+
},
1115+
default_answer="reuse",
1116+
)
1117+
11041118
def scan_existing_bugs(self, bugzilla: Bugzilla) -> bool:
11051119
all_packages = list({pkg[0].unversioned_atom for node in self.nodes for pkg in node.pkgs})
11061120
has_output = False
@@ -1137,16 +1151,19 @@ def scan_existing_bugs(self, bugzilla: Bugzilla) -> bool:
11371151
self.out.write(" -> bug summary: ", bug.summary)
11381152
if is_exact_match and node.bugno is None:
11391153
node.bugno = bug.id
1140-
elif userquery(
1141-
f"{'Duplicate of the matched bug' if is_exact_match else 'Not an exact match'}."
1142-
" Do you want to obsolete?",
1143-
self.out,
1144-
self.err,
1145-
default_answer=False,
1146-
):
1154+
elif is_exact_match:
1155+
if userquery(
1156+
"Duplicate of the matched bug. Do you want to obsolete?",
1157+
self.out,
1158+
self.err,
1159+
default_answer=False,
1160+
):
1161+
node.obsoletes.add(bug.id)
1162+
elif (answer := self._query_atom_match()) == "obsolete":
11471163
node.obsoletes.add(bug.id)
1148-
elif node.bugno is None:
1164+
elif answer == "reuse" and node.bugno is None:
11491165
node.bugno = bug.id
1166+
# "new" leaves the matched bug alone and files our own
11501167
has_output = True
11511168
return has_output
11521169

‎tests/scripts/test_pkgdev_bugs.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,10 @@ def _mk_graph(self, repo, monkeypatch, answer=True):
445445
graph.nodes = set()
446446
graph.starting_nodes = set()
447447
graph.modified_repo = None
448-
monkeypatch.setattr(bugs, "userquery", lambda *a, **k: answer)
448+
query = lambda *a, **k: (
449+
("obsolete" if answer else "reuse") if k.get("responses") else answer
450+
)
451+
monkeypatch.setattr(bugs, "userquery", query)
449452
return graph
450453

451454
@staticmethod

0 commit comments

Comments
 (0)