Skip to content

Commit f5b9550

Browse files
committed
bugs: add support for passing root blocker
Add option to pass `--blocks [bug_no]`. The "root" bugs (those corresponding to the starting nodes, those packages passed as args) will be created and block the passed bug. You can pass multiple bugs to block, separated by comma. Resolves: #139 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 2ba5b33 commit f5b9550

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

data/share/bash-completion/completions/pkgdev

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,14 @@ _pkgdev() {
234234
subcmd_options="
235235
--api-key
236236
--auto-cc-arches
237+
--blocks
237238
--dot
238239
-s --stablereq
239240
-k --keywording
240241
"
241242

242243
case "${prev}" in
243-
--api-key | --auto-cc-arches)
244+
--api-key | --auto-cc-arches | --blocks)
244245
COMPREPLY=()
245246
;;
246247
--dot)

src/pkgdev/scripts/pkgdev_bugs.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@
6767
package is maintainer-needed, always add CC-ARCHES.
6868
""",
6969
)
70+
bugs.add_argument(
71+
"--blocks",
72+
metavar="BUG",
73+
action=arghparse.CommaSeparatedValuesAppend,
74+
default=[],
75+
help="bugs which should be blocked by newly created bugs",
76+
docs="""
77+
Collection of bug ids which should be blocked by newly created bugs.
78+
Only bugs created for passed targets would be blockers, excluding other
79+
bugs which were created as dependencies.
80+
""",
81+
)
7082

7183
bugs.add_argument(
7284
"--cache",
@@ -183,7 +195,9 @@ def cleanup_keywords(self, repo):
183195
keywords.clear()
184196
keywords.add("*")
185197

186-
def file_bug(self, api_key: str, auto_cc_arches: frozenset[str], observer=None) -> int:
198+
def file_bug(
199+
self, api_key: str, auto_cc_arches: frozenset[str], block_bugs: list[int], observer=None
200+
) -> int:
187201
if self.bugno is not None:
188202
return self.bugno
189203
for dep in self.edges:
@@ -211,6 +225,7 @@ def file_bug(self, api_key: str, auto_cc_arches: frozenset[str], observer=None)
211225
assigned_to=maintainers[0],
212226
cc=maintainers[1:],
213227
depends_on=list({dep.bugno for dep in self.edges}),
228+
blocks=block_bugs,
214229
)
215230
request = urllib.Request(
216231
url="https://bugs.gentoo.org/rest/bug",
@@ -446,7 +461,7 @@ def scan_existing_bugs(self, api_key: str):
446461
)
447462
break
448463

449-
def file_bugs(self, api_key: str, auto_cc_arches: frozenset[str]):
464+
def file_bugs(self, api_key: str, auto_cc_arches: frozenset[str], block_bugs: list[int]):
450465
def observe(node: GraphNode):
451466
self.out.write(
452467
f"https://bugs.gentoo.org/{node.bugno} ",
@@ -457,7 +472,7 @@ def observe(node: GraphNode):
457472
self.out.flush()
458473

459474
for node in self.starting_nodes:
460-
node.file_bug(api_key, auto_cc_arches, observe)
475+
node.file_bug(api_key, auto_cc_arches, block_bugs, observe)
461476

462477

463478
def _load_from_stdin(out: Formatter, err: Formatter):
@@ -510,4 +525,5 @@ def main(options, out: Formatter, err: Formatter):
510525
return 1
511526

512527
disabled, enabled = options.auto_cc_arches
513-
d.file_bugs(options.api_key, frozenset(enabled).difference(disabled))
528+
blocks = list(frozenset(map(int, options.blocks)))
529+
d.file_bugs(options.api_key, frozenset(enabled).difference(disabled), blocks)

0 commit comments

Comments
 (0)