|
14 | 14 | from pkgcheck.addons import ArchesAddon, init_addon |
15 | 15 | from pkgcheck.addons.profiles import ProfileAddon |
16 | 16 | from pkgcheck.addons.git import GitAddon, GitModifiedRepo |
17 | | -from pkgcheck.checks import visibility |
| 17 | +from pkgcheck.checks import visibility, stablereq |
18 | 18 | from pkgcheck.scripts import argparse_actions |
19 | 19 | from pkgcore.ebuild.atom import atom |
20 | 20 | from pkgcore.ebuild.ebuild_src import package |
|
77 | 77 | to find matches, which can be slow (between 1 to 3 seconds). |
78 | 78 | """, |
79 | 79 | ) |
| 80 | +bugs.add_argument( |
| 81 | + "--filter-stablereqs", |
| 82 | + action="store_true", |
| 83 | + help="filter targets for packages with active StableRequest result", |
| 84 | + docs=""" |
| 85 | + Filter targets passed to pkgdev (command line, stabilization groups, |
| 86 | + maintainer search, stdin) for packages with active ``StableRequest`` |
| 87 | + result. |
| 88 | + """, |
| 89 | +) |
80 | 90 | bugs.add_argument( |
81 | 91 | "--blocks", |
82 | 92 | metavar="BUG", |
|
119 | 129 | help="File rekeywording bugs", |
120 | 130 | ) |
121 | 131 |
|
| 132 | +bugs.plugin = bugs |
122 | 133 | ArchesAddon.mangle_argparser(bugs) |
123 | 134 | GitAddon.mangle_argparser(bugs) |
124 | 135 | ProfileAddon.mangle_argparser(bugs) |
| 136 | +stablereq.StableRequestCheck.mangle_argparser(bugs) |
125 | 137 |
|
126 | 138 |
|
127 | 139 | @bugs.bind_delayed_default(1500, "target_repo") |
128 | 140 | def _validate_args(namespace, attr): |
129 | 141 | _determine_cwd_repo(bugs, namespace) |
130 | 142 | setattr(namespace, attr, namespace.repo) |
131 | 143 | setattr(namespace, "verbosity", 1) |
132 | | - setattr(namespace, "search_repo", multiplex.tree(*namespace.repo.trees)) |
| 144 | + setattr(namespace, "search_repo", search_repo := multiplex.tree(*namespace.repo.trees)) |
| 145 | + setattr(namespace, "gentoo_repo", search_repo) |
133 | 146 | setattr(namespace, "query_caching_freq", "package") |
134 | 147 |
|
135 | 148 |
|
@@ -286,6 +299,9 @@ def __init__(self, out: Formatter, err: Formatter, options): |
286 | 299 | self.starting_nodes: set[GraphNode] = set() |
287 | 300 | self.targets: tuple[package] = () |
288 | 301 |
|
| 302 | + git_addon = init_addon(GitAddon, options) |
| 303 | + self.stablereq_check = stablereq.StableRequestCheck(self.options, git_addon=git_addon) |
| 304 | + |
289 | 305 | def mk_fake_pkg(self, pkg: package, keywords: set[str]): |
290 | 306 | return FakePkg( |
291 | 307 | cpv=pkg.cpvstr, |
@@ -372,7 +388,15 @@ def load_targets(self, targets: list[tuple[str, str]]): |
372 | 388 | search_repo = self.options.search_repo |
373 | 389 | for _, target in targets: |
374 | 390 | try: |
375 | | - result.append(self.find_best_match([target], search_repo.match(target), False)) |
| 391 | + pkgset = search_repo.match(target) |
| 392 | + if self.options.filter_stablereqs: |
| 393 | + for res in self.stablereq_check.feed(sorted(pkgset)): |
| 394 | + if isinstance(res, stablereq.StableRequest): |
| 395 | + target = atom(f"={res.category}/{res.package}-{res.version}") |
| 396 | + break |
| 397 | + else: # no stablereq |
| 398 | + continue |
| 399 | + result.append(self.find_best_match([target], pkgset, False)) |
376 | 400 | except ValueError: |
377 | 401 | raise ValueError(f"Restriction {target} has no match in repository") |
378 | 402 | self.targets = tuple(result) |
|
0 commit comments