diff options
author | 2023-12-29 11:33:05 +0200 | |
---|---|---|
committer | 2023-12-29 14:33:11 +0200 | |
commit | 0177cb268d8aae77ab3ed92565a5fcd6eabc36a5 (patch) | |
tree | fd75321a41cf901a64189caf0ce26d23b443daf3 | |
parent | bugs: improve best match finder (diff) | |
download | pkgdev-0177cb268d8aae77ab3ed92565a5fcd6eabc36a5.tar.gz pkgdev-0177cb268d8aae77ab3ed92565a5fcd6eabc36a5.tar.bz2 pkgdev-0177cb268d8aae77ab3ed92565a5fcd6eabc36a5.zip |
bugs: add ``--find-by-maintainer`` option
Scan over the whole repository to find packages maintained by passed
emails. It would try to find best stable candidate from that package.
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 | 3 | ||||
-rw-r--r-- | src/pkgdev/scripts/pkgdev_bugs.py | 30 |
2 files changed, 32 insertions, 1 deletions
diff --git a/data/share/bash-completion/completions/pkgdev b/data/share/bash-completion/completions/pkgdev index bbad831..33bcb03 100644 --- a/data/share/bash-completion/completions/pkgdev +++ b/data/share/bash-completion/completions/pkgdev @@ -246,6 +246,7 @@ _pkgdev() { subcmd_options=" --api-key --auto-cc-arches + --find-by-maintainer --blocks --dot -s --stablereq @@ -253,7 +254,7 @@ _pkgdev() { " case "${prev}" in - --api-key | --auto-cc-arches | --blocks) + --api-key | --auto-cc-arches | --blocks | --find-by-maintainer) COMPREPLY=() ;; --dot) diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py index 21f242f..0203c47 100644 --- a/src/pkgdev/scripts/pkgdev_bugs.py +++ b/src/pkgdev/scripts/pkgdev_bugs.py @@ -20,6 +20,7 @@ from pkgcore.ebuild.atom import atom from pkgcore.ebuild.ebuild_src import package from pkgcore.ebuild.errors import MalformedAtom from pkgcore.ebuild.misc import sort_keywords +from pkgcore.ebuild.repo_objs import LocalMetadataXml from pkgcore.repository import multiplex from pkgcore.restrictions import boolean, packages, values from pkgcore.test.misc import FakePkg @@ -27,6 +28,7 @@ from pkgcore.util import commandline, parserestrict from snakeoil.cli import arghparse from snakeoil.cli.input import userquery from snakeoil.formatters import Formatter +from snakeoil.osutils import pjoin from ..cli import ArgumentParser from .argparsers import _determine_cwd_repo, cwd_repo_argparser, BugzillaApiKey @@ -63,6 +65,19 @@ bugs.add_argument( """, ) bugs.add_argument( + "--find-by-maintainer", + action=arghparse.CommaSeparatedNegationsAppend, + default=([], []), + help="collect all packages maintained by the listed email addresses", + docs=""" + Comma separated list of email addresses, for which pkgdev will collect + all packages maintained by. + + Note that this flag requires to go over all packages in the repository + to find matches, which can be slow (between 1 to 3 seconds). + """, +) +bugs.add_argument( "--blocks", metavar="BUG", action=arghparse.CommaSeparatedValuesAppend, @@ -309,6 +324,20 @@ class DependencyGraph: except (ValueError, IndexError): self.err.write(f"Unable to find match for {pkg.unversioned_atom}") + def extend_maintainers(self): + disabled, enabled = self.options.find_by_maintainer + emails = frozenset(enabled).difference(disabled) + if not emails: + return + search_repo = self.options.search_repo + self.out.write("Searching for packages maintained by: ", ", ".join(emails)) + self.out.flush() + for cat, pkgs in search_repo.packages.items(): + for pkg in pkgs: + xml = LocalMetadataXml(pjoin(search_repo.location[0], cat, pkg, "metadata.xml")) + if emails.intersection(m.email for m in xml.maintainers): + yield None, parserestrict.parse_match(f"{cat}/{pkg}") + def _find_dependencies(self, pkg: package, keywords: set[str]): check = visibility.VisibilityCheck(self.options, profile_addon=self.profile_addon) @@ -551,6 +580,7 @@ def main(options, out: Formatter, err: Formatter): search_repo = options.search_repo options.targets = options.targets or [] d = DependencyGraph(out, err, options) + options.targets.extend(d.extend_maintainers()) options.targets.extend(d.extend_targets_stable_groups(options.sets or ())) if not options.targets: options.targets = list(_load_from_stdin(out, err)) |