diff options
author | 2023-12-29 13:24:31 +0200 | |
---|---|---|
committer | 2023-12-29 14:33:11 +0200 | |
commit | fd2d7cdb36e483623b0c46d1beda5f65232c73f4 (patch) | |
tree | 1974144fa8bc9869a58aae572e57b74529cad127 | |
parent | bugs: add support for filtering targets by StableRequest (diff) | |
download | pkgdev-fd2d7cdb36e483623b0c46d1beda5f65232c73f4.tar.gz pkgdev-fd2d7cdb36e483623b0c46d1beda5f65232c73f4.tar.bz2 pkgdev-fd2d7cdb36e483623b0c46d1beda5f65232c73f4.zip |
bugs: auto extend maintainers with projects
When ``--projects`` is passed, fetch ``projects.xml``, and extent the
maintainers list with projects whose members include maintainers.
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 | 1 | ||||
-rw-r--r-- | src/pkgdev/scripts/pkgdev_bugs.py | 30 |
2 files changed, 30 insertions, 1 deletions
diff --git a/data/share/bash-completion/completions/pkgdev b/data/share/bash-completion/completions/pkgdev index acb4f68..98c2001 100644 --- a/data/share/bash-completion/completions/pkgdev +++ b/data/share/bash-completion/completions/pkgdev @@ -247,6 +247,7 @@ _pkgdev() { --api-key --auto-cc-arches --find-by-maintainer + --projects --filter-stablereqs --stabletime --blocks diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py index a3c6c3a..fb60ff1 100644 --- a/src/pkgdev/scripts/pkgdev_bugs.py +++ b/src/pkgdev/scripts/pkgdev_bugs.py @@ -20,13 +20,14 @@ 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.ebuild.repo_objs import LocalMetadataXml, ProjectsXml from pkgcore.repository import multiplex from pkgcore.restrictions import boolean, packages, values from pkgcore.test.misc import FakePkg from pkgcore.util import commandline, parserestrict from snakeoil.cli import arghparse from snakeoil.cli.input import userquery +from snakeoil.data_source import bytes_data_source from snakeoil.formatters import Formatter from snakeoil.osutils import pjoin @@ -78,6 +79,18 @@ bugs.add_argument( """, ) bugs.add_argument( + "--projects", + action="store_true", + help="include packages maintained by projects", + docs=""" + Include packages maintained by projects, whose members include the + emails of maintainers passed to ``--find-by-maintainer``. + + Note that this flag requires to fetch the ``projects.xml`` file from + ``https://api.gentoo.org``. + """, +) +bugs.add_argument( "--filter-stablereqs", action="store_true", help="filter targets for packages with active StableRequest result", @@ -340,8 +353,23 @@ class DependencyGraph: except (ValueError, IndexError): self.err.write(f"Unable to find match for {pkg.unversioned_atom}") + def _extend_projects(self, disabled, enabled): + members = defaultdict(set) + self.out.write("Fetching projects.xml") + self.out.flush() + with urllib.urlopen("https://api.gentoo.org/metastructure/projects.xml", timeout=30) as f: + for email, project in ProjectsXml(bytes_data_source(f.read())).projects.items(): + for member in project.members: + members[member.email].add(email) + + disabled = frozenset(disabled).union(*(members[email] for email in disabled)) + enabled = frozenset(enabled).union(*(members[email] for email in enabled)) + return disabled, enabled + def extend_maintainers(self): disabled, enabled = self.options.find_by_maintainer + if self.options.projects: + disabled, enabled = self._extend_projects(disabled, enabled) emails = frozenset(enabled).difference(disabled) if not emails: return |