diff options
author | 2023-12-29 12:20:45 +0200 | |
---|---|---|
committer | 2023-12-29 14:33:11 +0200 | |
commit | eb2960caeb5582fad6962edd19614dd361fa115f (patch) | |
tree | 2cec476f786c65ed115eb4a8f171a3a5d56867fe | |
parent | bugs: add ``--find-by-maintainer`` option (diff) | |
download | pkgdev-eb2960caeb5582fad6962edd19614dd361fa115f.tar.gz pkgdev-eb2960caeb5582fad6962edd19614dd361fa115f.tar.bz2 pkgdev-eb2960caeb5582fad6962edd19614dd361fa115f.zip |
bugs: add support for filtering targets by StableRequest
Add ``--filter-stablereqs`` and ``--stabletime`` to filter targets for
those which have ready StableRequest pkgcheck result.
Resolves: https://github.com/pkgcore/pkgdev/issues/157
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | data/share/bash-completion/completions/pkgdev | 4 | ||||
-rw-r--r-- | src/pkgdev/scripts/pkgdev_bugs.py | 30 |
2 files changed, 30 insertions, 4 deletions
diff --git a/data/share/bash-completion/completions/pkgdev b/data/share/bash-completion/completions/pkgdev index 33bcb03..acb4f68 100644 --- a/data/share/bash-completion/completions/pkgdev +++ b/data/share/bash-completion/completions/pkgdev @@ -247,6 +247,8 @@ _pkgdev() { --api-key --auto-cc-arches --find-by-maintainer + --filter-stablereqs + --stabletime --blocks --dot -s --stablereq @@ -254,7 +256,7 @@ _pkgdev() { " case "${prev}" in - --api-key | --auto-cc-arches | --blocks | --find-by-maintainer) + --api-key | --auto-cc-arches | --blocks | --find-by-maintainer | --stabletime) COMPREPLY=() ;; --dot) diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py index 0203c47..a3c6c3a 100644 --- a/src/pkgdev/scripts/pkgdev_bugs.py +++ b/src/pkgdev/scripts/pkgdev_bugs.py @@ -14,7 +14,7 @@ from pkgcheck import const as pkgcheck_const from pkgcheck.addons import ArchesAddon, init_addon from pkgcheck.addons.profiles import ProfileAddon from pkgcheck.addons.git import GitAddon, GitModifiedRepo -from pkgcheck.checks import visibility +from pkgcheck.checks import visibility, stablereq from pkgcheck.scripts import argparse_actions from pkgcore.ebuild.atom import atom from pkgcore.ebuild.ebuild_src import package @@ -78,6 +78,16 @@ bugs.add_argument( """, ) bugs.add_argument( + "--filter-stablereqs", + action="store_true", + help="filter targets for packages with active StableRequest result", + docs=""" + Filter targets passed to pkgdev (command line, stabilization groups, + maintainer search, stdin) for packages with active ``StableRequest`` + result. + """, +) +bugs.add_argument( "--blocks", metavar="BUG", action=arghparse.CommaSeparatedValuesAppend, @@ -119,9 +129,11 @@ bugs_state.add_argument( help="File rekeywording bugs", ) +bugs.plugin = bugs ArchesAddon.mangle_argparser(bugs) GitAddon.mangle_argparser(bugs) ProfileAddon.mangle_argparser(bugs) +stablereq.StableRequestCheck.mangle_argparser(bugs) @bugs.bind_delayed_default(1500, "target_repo") @@ -129,7 +141,8 @@ def _validate_args(namespace, attr): _determine_cwd_repo(bugs, namespace) setattr(namespace, attr, namespace.repo) setattr(namespace, "verbosity", 1) - setattr(namespace, "search_repo", multiplex.tree(*namespace.repo.trees)) + setattr(namespace, "search_repo", search_repo := multiplex.tree(*namespace.repo.trees)) + setattr(namespace, "gentoo_repo", search_repo) setattr(namespace, "query_caching_freq", "package") @@ -286,6 +299,9 @@ class DependencyGraph: self.starting_nodes: set[GraphNode] = set() self.targets: tuple[package] = () + git_addon = init_addon(GitAddon, options) + self.stablereq_check = stablereq.StableRequestCheck(self.options, git_addon=git_addon) + def mk_fake_pkg(self, pkg: package, keywords: set[str]): return FakePkg( cpv=pkg.cpvstr, @@ -372,7 +388,15 @@ class DependencyGraph: search_repo = self.options.search_repo for _, target in targets: try: - result.append(self.find_best_match([target], search_repo.match(target), False)) + pkgset = search_repo.match(target) + if self.options.filter_stablereqs: + for res in self.stablereq_check.feed(sorted(pkgset)): + if isinstance(res, stablereq.StableRequest): + target = atom(f"={res.category}/{res.package}-{res.version}") + break + else: # no stablereq + continue + result.append(self.find_best_match([target], pkgset, False)) except ValueError: raise ValueError(f"Restriction {target} has no match in repository") self.targets = tuple(result) |