public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: data/share/bash-completion/completions/, src/pkgdev/scripts/
@ 2023-12-30 10:45 Arthur Zamarin
  0 siblings, 0 replies; 4+ messages in thread
From: Arthur Zamarin @ 2023-12-30 10:45 UTC (permalink / raw
  To: gentoo-commits

commit:     eb2960caeb5582fad6962edd19614dd361fa115f
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 29 10:20:45 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 29 12:33:11 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=eb2960ca

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 <AT> gentoo.org>

 data/share/bash-completion/completions/pkgdev |  4 +++-
 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
@@ -77,6 +77,16 @@ bugs.add_argument(
         to find matches, which can be slow (between 1 to 3 seconds).
     """,
 )
+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",
@@ -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)


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: data/share/bash-completion/completions/, src/pkgdev/scripts/
@ 2023-12-30 10:45 Arthur Zamarin
  0 siblings, 0 replies; 4+ messages in thread
From: Arthur Zamarin @ 2023-12-30 10:45 UTC (permalink / raw
  To: gentoo-commits

commit:     fd2d7cdb36e483623b0c46d1beda5f65232c73f4
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 29 11:24:31 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 29 12:33:11 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=fd2d7cdb

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 <AT> gentoo.org>

 data/share/bash-completion/completions/pkgdev |  1 +
 src/pkgdev/scripts/pkgdev_bugs.py             | 30 ++++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

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
 
@@ -77,6 +78,18 @@ bugs.add_argument(
         to find matches, which can be slow (between 1 to 3 seconds).
     """,
 )
+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",
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: data/share/bash-completion/completions/, src/pkgdev/scripts/
@ 2023-12-30 10:45 Arthur Zamarin
  0 siblings, 0 replies; 4+ messages in thread
From: Arthur Zamarin @ 2023-12-30 10:45 UTC (permalink / raw
  To: gentoo-commits

commit:     0177cb268d8aae77ab3ed92565a5fcd6eabc36a5
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 29 09:33:05 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 29 12:33:11 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=0177cb26

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 <AT> gentoo.org>

 data/share/bash-completion/completions/pkgdev |  3 ++-
 src/pkgdev/scripts/pkgdev_bugs.py             | 30 +++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

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
@@ -62,6 +64,19 @@ bugs.add_argument(
         package is maintainer-needed, always add CC-ARCHES.
     """,
 )
+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",
@@ -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))


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: data/share/bash-completion/completions/, src/pkgdev/scripts/
@ 2024-05-19 16:04 Arthur Zamarin
  0 siblings, 0 replies; 4+ messages in thread
From: Arthur Zamarin @ 2024-05-19 16:04 UTC (permalink / raw
  To: gentoo-commits

commit:     a4520f899ca1714303e7a4ad569ba66acf3ac0db
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri May 17 14:32:38 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat May 18 18:35:14 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=a4520f89

mask: support auto filing of last-rite bug & PMASKED bugs

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 data/share/bash-completion/completions/pkgdev |   4 +-
 src/pkgdev/scripts/pkgdev_mask.py             | 151 ++++++++++++++++++++------
 2 files changed, 119 insertions(+), 36 deletions(-)

diff --git a/data/share/bash-completion/completions/pkgdev b/data/share/bash-completion/completions/pkgdev
index ab3e4c6..09bfbf7 100644
--- a/data/share/bash-completion/completions/pkgdev
+++ b/data/share/bash-completion/completions/pkgdev
@@ -121,10 +121,12 @@ _pkgdev() {
                 -r --rites
                 -b --bug
                 --email
+                --api-key
+                --file-bug
             "
 
             case "${prev}" in
-                -[rb] | --rites | --bugs)
+                -[rb] | --rites | --bugs | --api-key)
                     COMPREPLY=()
                     ;;
                 *)

diff --git a/src/pkgdev/scripts/pkgdev_mask.py b/src/pkgdev/scripts/pkgdev_mask.py
index 4ce2984..041eef1 100644
--- a/src/pkgdev/scripts/pkgdev_mask.py
+++ b/src/pkgdev/scripts/pkgdev_mask.py
@@ -1,9 +1,11 @@
+import json
 import os
 import re
 import shlex
 import subprocess
 import tempfile
 import textwrap
+import urllib.request as urllib
 from collections import deque
 from dataclasses import dataclass
 from datetime import datetime, timedelta, timezone
@@ -20,13 +22,14 @@ from snakeoil.osutils import pjoin
 from snakeoil.strings import pluralism
 
 from .. import git
-from .argparsers import cwd_repo_argparser, git_repo_argparser
+from .argparsers import cwd_repo_argparser, git_repo_argparser, BugzillaApiKey
 
 mask = arghparse.ArgumentParser(
     prog="pkgdev mask",
     description="mask packages",
     parents=(cwd_repo_argparser, git_repo_argparser),
 )
+BugzillaApiKey.mangle_argparser(mask)
 mask.add_argument(
     "targets",
     metavar="TARGET",
@@ -81,11 +84,26 @@ mask_opts.add_argument(
         ``x11-misc/xdg-utils`` package.
     """,
 )
+mask_opts.add_argument(
+    "--file-bug",
+    action="store_true",
+    help="file a last-rite bug",
+    docs="""
+        Files a last-rite bug for the masked package, which blocks listed
+        reference bugs. ``PMASKED`` keyword is added all all referenced bugs.
+    """,
+)
 
 
 @mask.bind_final_check
 def _mask_validate(parser, namespace):
-    atoms = []
+    atoms = set()
+    maintainers = set()
+
+    if not namespace.rites and namespace.file_bug:
+        mask.error("bug filing requires last rites")
+    if namespace.file_bug and not namespace.api_key:
+        mask.error("bug filing requires a Bugzilla API key")
 
     if namespace.email and not namespace.rites:
         mask.error("last rites required for email support")
@@ -96,23 +114,30 @@ def _mask_validate(parser, namespace):
                 restrict = namespace.repo.path_restrict(x)
                 pkg = next(namespace.repo.itermatch(restrict))
                 atom = pkg.versioned_atom
+                maintainers.update(maintainer.email for maintainer in pkg.maintainers)
             else:
                 try:
                     atom = atom_cls(x)
                 except MalformedAtom:
                     mask.error(f"invalid atom: {x!r}")
-                if not namespace.repo.match(atom):
+                if pkgs := namespace.repo.match(atom):
+                    maintainers.update(
+                        maintainer.email for pkg in pkgs for maintainer in pkg.maintainers
+                    )
+                else:
                     mask.error(f"no repo matches: {x!r}")
-            atoms.append(atom)
+            atoms.add(atom)
     else:
         restrict = namespace.repo.path_restrict(os.getcwd())
         # repo, category, and package level restricts
         if len(restrict) != 3:
             mask.error("not in a package directory")
         pkg = next(namespace.repo.itermatch(restrict))
-        atoms.append(pkg.unversioned_atom)
+        atoms.add(pkg.unversioned_atom)
+        maintainers.update(maintainer.email for maintainer in pkg.maintainers)
 
     namespace.atoms = sorted(atoms)
+    namespace.maintainers = sorted(maintainers) or ["maintainer-needed@gentoo.org"]
 
 
 @dataclass(frozen=True)
@@ -208,38 +233,24 @@ class MaskFile:
         return "".join(self.header) + "\n\n".join(map(str, self.masks))
 
 
-def get_comment(bugs, rites: int):
+def get_comment():
     """Spawn editor to get mask comment."""
     tmp = tempfile.NamedTemporaryFile(mode="w")
-    summary = []
-    if rites:
-        summary.append(f"Removal on {datetime.now(timezone.utc) + timedelta(days=rites):%Y-%m-%d}.")
-    if bugs:
-        # Bug(s) #A, #B, #C
-        bug_list = ", ".join(f"#{b}" for b in bugs)
-        s = pluralism(bugs)
-        summary.append(f"Bug{s} {bug_list}.")
-    if summary := "  ".join(summary):
-        tmp.write(f"\n{summary}")
     tmp.write(
         textwrap.dedent(
             """
 
                 # Please enter the mask message. Lines starting with '#' will be ignored.
                 #
-                # - Best last rites (removal) practices -
+                # If last-rite was requested, it would be added automatically.
                 #
-                # Include the following info:
-                # a) reason for masking
-                # b) bug # for the removal (and yes you should have one)
-                # c) date of removal (either the date or "in x days")
+                # For rules on writing mask messages, see GLEP-84:
+                #   https://glep.gentoo.org/glep-0084.html
                 #
                 # Example:
                 #
-                # Masked for removal in 30 days.  Doesn't work
-                # with new libfoo. Upstream dead, gtk-1, smells
+                # Doesn't work with new libfoo. Upstream dead, gtk-1, smells
                 # funny.
-                # Bug #987654
             """
         )
     )
@@ -262,10 +273,71 @@ def get_comment(bugs, rites: int):
     comment = "\n".join(comment).strip().splitlines()
     if not comment:
         mask.error("empty mask comment")
-
     return comment
 
 
+def message_removal_notice(bugs: list[int], rites: int):
+    summary = []
+    if rites:
+        summary.append(f"Removal on {datetime.now(timezone.utc) + timedelta(days=rites):%Y-%m-%d}.")
+    if bugs:
+        # Bug(s) #A, #B, #C
+        bug_list = ", ".join(f"#{b}" for b in bugs)
+        s = pluralism(bugs)
+        summary.append(f"Bug{s} {bug_list}.")
+    return "  ".join(summary)
+
+
+def file_last_rites_bug(options, message: str) -> int:
+    summary = f"{', '.join(map(str, options.atoms))}: removal"
+    if len(summary) > 90 and len(options.atoms) > 1:
+        summary = f"{options.atoms[0]} and friends: removal"
+    request_data = dict(
+        Bugzilla_api_key=options.api_key,
+        product="Gentoo Linux",
+        component="Current packages",
+        version="unspecified",
+        summary=summary,
+        description="\n".join([*message, "", "package list:", *map(str, options.atoms)]).strip(),
+        keywords=["PMASKED"],
+        assigned_to=options.maintainers[0],
+        cc=options.maintainers[1:] + ["treecleaner@gentoo.org"],
+        deadline=(datetime.now(timezone.utc) + timedelta(days=options.rites)).strftime("%Y-%m-%d"),
+        blocks=list(options.bugs),
+    )
+    request = urllib.Request(
+        url="https://bugs.gentoo.org/rest/bug",
+        data=json.dumps(request_data).encode("utf-8"),
+        method="POST",
+        headers={
+            "Content-Type": "application/json",
+            "Accept": "application/json",
+        },
+    )
+    with urllib.urlopen(request, timeout=30) as response:
+        reply = json.loads(response.read().decode("utf-8"))
+    return int(reply["id"])
+
+
+def update_bugs_pmasked(api_key: str, bugs: list[int]):
+    request_data = dict(
+        Bugzilla_api_key=api_key,
+        ids=bugs,
+        keywords=dict(add=["PMASKED"]),
+    )
+    request = urllib.Request(
+        url=f"https://bugs.gentoo.org/rest/bug/{bugs[0]}",
+        data=json.dumps(request_data).encode("utf-8"),
+        method="PUT",
+        headers={
+            "Content-Type": "application/json",
+            "Accept": "application/json",
+        },
+    )
+    with urllib.urlopen(request, timeout=30) as response:
+        return response.status == 200
+
+
 def send_last_rites_email(m: Mask, subject_prefix: str):
     try:
         atoms = ", ".join(map(str, m.atoms))
@@ -298,16 +370,25 @@ def _mask(options, out, err):
     p = git.run("config", "user.email", stdout=subprocess.PIPE)
     email = p.stdout.strip()
 
-    # initial args for Mask obj
-    mask_args = {
-        "author": author,
-        "email": email,
-        "date": today.strftime("%Y-%m-%d"),
-        "comment": get_comment(options.bugs, options.rites),
-        "atoms": options.atoms,
-    }
-
-    m = Mask(**mask_args)
+    message = get_comment()
+    if options.file_bug:
+        if bug_no := file_last_rites_bug(options, message):
+            out.write(out.fg("green"), f"filed bug https://bugs.gentoo.org/{bug_no}", out.reset)
+            out.flush()
+            if not update_bugs_pmasked(options.api_key, options.bugs):
+                err.write(err.fg("red"), "failed to update referenced bugs", err.reset)
+                err.flush()
+            options.bugs.insert(0, bug_no)
+    if removal := message_removal_notice(options.bugs, options.rites):
+        message.append(removal)
+
+    m = Mask(
+        author=author,
+        email=email,
+        date=today.strftime("%Y-%m-%d"),
+        comment=message,
+        atoms=options.atoms,
+    )
     mask_file.add(m)
     mask_file.write()
 


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-19 16:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-30 10:45 [gentoo-commits] proj/pkgcore/pkgdev:main commit in: data/share/bash-completion/completions/, src/pkgdev/scripts/ Arthur Zamarin
  -- strict thread matches above, loose matches on Subject: below --
2023-12-30 10:45 Arthur Zamarin
2023-12-30 10:45 Arthur Zamarin
2024-05-19 16:04 Arthur Zamarin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox