public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2022-10-04  8:03 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2022-10-04  8:03 UTC (permalink / raw
  To: gentoo-commits

commit:     810cf6978686c58da614bff4ba87b31355c82107
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Oct  4 07:59:04 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Oct  4 07:59:04 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=810cf697

commit: add `--distdir` for manifest operations

Resolves: https://github.com/pkgcore/pkgdev/issues/99
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_commit.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_commit.py b/src/pkgdev/scripts/pkgdev_commit.py
index dded6d4..20fd471 100644
--- a/src/pkgdev/scripts/pkgdev_commit.py
+++ b/src/pkgdev/scripts/pkgdev_commit.py
@@ -129,10 +129,16 @@ commit_opts.add_argument(
         Add a Signed-off-by trailer by the committer at the end of the commit
         log message.
 
-        For commiting to the Gentoo repository, under GLEP-76, the commiter
+        For committing to the Gentoo repository, under GLEP-76, the committer
         shall certify agreement to the Certificate of Origin by adding
         Signed-off-by line containing the committer's legal name.
     """)
+commit_opts.add_argument(
+    '-d', '--distdir', type=arghparse.create_dir, help='target download directory',
+    docs="""
+        Use a specified target directory for downloads instead of the
+        configured DISTDIR.
+    """)
 
 msg_actions = commit_opts.add_mutually_exclusive_group()
 msg_actions.add_argument(
@@ -761,7 +767,8 @@ def update_manifests(options, out, err, changes):
             # manifest all staged or committed packages
             failed = repo.operations.manifest(
                 options.domain, packages.OrRestriction(*pkgs),
-                observer=observer_mod.formatter_output(out))
+                observer=observer_mod.formatter_output(out),
+                distdir=options.distdir)
             if any(failed):
                 return 1
 


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2022-11-19 12:51 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2022-11-19 12:51 UTC (permalink / raw
  To: gentoo-commits

commit:     96ab6d86cad0536dbccb4f3e0cea5e781f46772f
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 19 12:29:29 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 19 12:29:29 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=96ab6d86

showkw: use color 90 instead of 30

More terminals are showing it as gray, instead of 30, which some where
showing as black fg over black bg.

Requested by: Ulrich Müller <ulm <AT> gentoo.org>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_showkw.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_showkw.py b/src/pkgdev/scripts/pkgdev_showkw.py
index 27a5a25..cb9c35c 100644
--- a/src/pkgdev/scripts/pkgdev_showkw.py
+++ b/src/pkgdev/scripts/pkgdev_showkw.py
@@ -153,7 +153,7 @@ def _validate_args(parser, namespace):
             '~': '\u001b[33m',
             '-': '\u001b[31m',
             '*': '\u001b[31m',
-            'o': '\u001b[30;1m',
+            'o': '\u001b[90;1m',
             'reset': '\u001b[0m',
         }
     else:


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-01-13 21:07 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-01-13 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     2c287a73c58daec216f1a79eb70140ae5e2bfb9e
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 13 21:05:35 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jan 13 21:05:35 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=2c287a73

commit: enable -e usage with -M or -m

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

 src/pkgdev/scripts/pkgdev_commit.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_commit.py b/src/pkgdev/scripts/pkgdev_commit.py
index 98f09d1..03dfdb6 100644
--- a/src/pkgdev/scripts/pkgdev_commit.py
+++ b/src/pkgdev/scripts/pkgdev_commit.py
@@ -163,7 +163,7 @@ msg_actions.add_argument(
     """)
 msg_actions.add_argument('-F', '--file', help=argparse.SUPPRESS)
 msg_actions.add_argument('-t', '--template', help=argparse.SUPPRESS)
-msg_actions.add_argument(
+commit_opts.add_argument(
     '-e', '--edit', action='store_true',
     help='force edit of commit',
     docs="""


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-01-13 21:39 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-01-13 21:39 UTC (permalink / raw
  To: gentoo-commits

commit:     0ba8f7d35582638fcc2b6d457a2e46702b8d9ca6
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 13 21:37:47 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jan 13 21:37:47 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=0ba8f7d3

commit: update help text for `--edit`

Suggested-by: Jonas Stein <jstein <AT> gentoo.org>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_commit.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_commit.py b/src/pkgdev/scripts/pkgdev_commit.py
index 1373b35..162a8f7 100644
--- a/src/pkgdev/scripts/pkgdev_commit.py
+++ b/src/pkgdev/scripts/pkgdev_commit.py
@@ -167,9 +167,8 @@ commit_opts.add_argument(
     '-e', '--edit', action='store_true',
     help='force edit of commit',
     docs="""
-        The message taken from command line with -m, and from automatically
-        generated one are usually used as the commit log message unmodified.
-        This option lets you further edit the message taken from these sources.
+        This option will ask git to open the commit message in an editor before
+        commit. The git configuration is used to select the editor.
     """)
 
 add_actions = commit_opts.add_mutually_exclusive_group()


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-03-04 15:05 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-03-04 15:05 UTC (permalink / raw
  To: gentoo-commits

commit:     ff2c851225dce45ca03b9be994fccb6e28fdd7c4
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  4 15:04:57 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Mar  4 15:04:57 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=ff2c8512

commit: use removeprefix

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

 src/pkgdev/scripts/pkgdev_commit.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_commit.py b/src/pkgdev/scripts/pkgdev_commit.py
index bcf6463..c85c7b1 100644
--- a/src/pkgdev/scripts/pkgdev_commit.py
+++ b/src/pkgdev/scripts/pkgdev_commit.py
@@ -765,11 +765,9 @@ def determine_msg_args(options, changes):
         args.extend(["-t", options.template])
     else:
         if options.message_template:
-            message = options.message_template.read().splitlines()
+            message: list[str] = options.message_template.read().splitlines()
             try:
-                # TODO: replace with str.removeprefix when py3.8 support dropped
-                if message[0].startswith("*: "):
-                    message[0] = message[0][3:]
+                message[0] = message[0].removeprefix("*: ")
             except IndexError:
                 commit.error(f"empty message template: {options.message_template.name!r}")
         else:


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-03-05 19:55 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-03-05 19:55 UTC (permalink / raw
  To: gentoo-commits

commit:     41b813487245d68407640a36ece5d2320e6c1af9
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Mar  5 19:52:58 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Mar  5 19:52:58 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=41b81348

commit: compute commit title for commit related files only

In cases were multiples files are staged for commit across packages, but
we run `pkgdev commit .` in one of them, it was adding and committing
only the current package, but computing the message based on both of
them.

Resolves: https://github.com/pkgcore/pkgdev/issues/122
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_commit.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/pkgdev/scripts/pkgdev_commit.py b/src/pkgdev/scripts/pkgdev_commit.py
index c85c7b1..98cbb78 100644
--- a/src/pkgdev/scripts/pkgdev_commit.py
+++ b/src/pkgdev/scripts/pkgdev_commit.py
@@ -48,6 +48,9 @@ class ArgumentParser(cli.ArgumentParser):
         if namespace.edit:
             args.append("--edit")
         namespace.commit_args = args
+        namespace.git_args_paths = list(
+            filter(os.path.exists, (s for s in args if not s.startswith("-")))
+        )
         return namespace, []
 
 
@@ -575,6 +578,7 @@ class GitChanges(UserDict):
             "--cached",
             "-z",
             "HEAD",
+            *self._options.git_args_paths,
             stdout=subprocess.PIPE,
         )
 


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-03-11 16:07 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-03-11 16:07 UTC (permalink / raw
  To: gentoo-commits

commit:     5e4b3ec570db73ab340bc2d65d01342eb0ae823a
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 11 16:06:51 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Mar 11 16:06:51 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=5e4b3ec5

bugs: improve assert for unkeyworded packages

Bug: https://github.com/pkgcore/pkgdev/issues/123
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 5ea32e6..814aec1 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -286,7 +286,9 @@ class DependencyGraph:
                 continue
 
             keywords.update(_get_suggested_keywords(self.options.repo, pkg))
-            assert keywords
+            assert (
+                keywords
+            ), f"no keywords for {pkg.versioned_atom}, currently unsupported by tool: https://github.com/pkgcore/pkgdev/issues/123"
             self.nodes.add(new_node := GraphNode(((pkg, keywords),)))
             vertices[pkg] = new_node
             self.out.write(


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-03-18 18:20 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-03-18 18:20 UTC (permalink / raw
  To: gentoo-commits

commit:     0a65605990539e229ac7262f1e9c50509074a81c
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 18 18:19:52 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Mar 18 18:19:52 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=0a656059

bugs: handle correctly merge on new keywords of starting point

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

 src/pkgdev/scripts/pkgdev_bugs.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 814aec1..cb1bf0c 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -318,6 +318,7 @@ class DependencyGraph:
 
     def merge_nodes(self, nodes: tuple[GraphNode, ...]) -> GraphNode:
         self.nodes.difference_update(nodes)
+        is_start = bool(self.starting_nodes.intersection(nodes))
         self.starting_nodes.difference_update(nodes)
         new_node = GraphNode(list(chain.from_iterable(n.pkgs for n in nodes)))
 
@@ -330,6 +331,8 @@ class DependencyGraph:
                 node.edges.add(new_node)
 
         self.nodes.add(new_node)
+        if is_start:
+            self.starting_nodes.add(new_node)
         return new_node
 
     @staticmethod
@@ -345,17 +348,15 @@ class DependencyGraph:
         return ()
 
     def merge_cycles(self):
-        new_starts = set()
-        while self.starting_nodes:
-            starting_node = self.starting_nodes.pop()
+        start_nodes = set(self.starting_nodes)
+        while start_nodes:
+            starting_node = start_nodes.pop()
             assert starting_node in self.nodes
             while cycle := self._find_cycles(tuple(self.nodes), [starting_node]):
-                print("Found cycle:", " -> ".join(str(n) for n in cycle))
+                self.out.write("Found cycle: ", " -> ".join(str(n) for n in cycle))
                 new_node = self.merge_nodes(cycle)
                 if starting_node not in self.nodes:
                     starting_node = new_node
-            new_starts.add(starting_node)
-        self.starting_nodes.update(new_starts)
 
     def merge_new_keywords_children(self):
         repo = self.options.search_repo
@@ -379,7 +380,7 @@ class DependencyGraph:
                 if existing_keywords & frozenset().union(*(pkg[1] for pkg in node.pkgs)):
                     continue  # not fully new keywords
                 orig = next(iter(origs))
-                print(f"Merging {node} into {orig}")
+                self.out.write(f"Merging {node} into {orig}")
                 self.merge_nodes((orig, node))
                 found_someone = True
                 break


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-03-27 18:38 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-03-27 18:38 UTC (permalink / raw
  To: gentoo-commits

commit:     2362b255c1712be7ae0442309950835ddaadce08
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 27 18:37:55 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Mar 27 18:37:55 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=2362b255

bugs: query for existing open bugs

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

 src/pkgdev/scripts/pkgdev_bugs.py | 59 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index cb1bf0c..4cf726a 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -5,6 +5,7 @@ import urllib.request as urllib
 from collections import defaultdict
 from functools import partial
 from itertools import chain
+from urllib.parse import urlencode
 
 from pkgcheck import const as pkgcheck_const
 from pkgcheck.addons import ArchesAddon, init_addon
@@ -13,6 +14,7 @@ from pkgcheck.checks import visibility
 from pkgcheck.scripts import argparse_actions
 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.repository import multiplex
 from pkgcore.restrictions import boolean, packages, values
@@ -127,6 +129,16 @@ def _get_suggested_keywords(repo, pkg: package):
     return frozenset({x for x in match_keywords if "-" not in x})
 
 
+def parse_atom(pkg: str):
+    try:
+        return atom(pkg)
+    except MalformedAtom as exc:
+        try:
+            return atom(f"={pkg}")
+        except MalformedAtom:
+            raise exc
+
+
 class GraphNode:
     __slots__ = ("pkgs", "edges", "bugno")
 
@@ -267,7 +279,7 @@ class DependencyGraph:
                 combined = boolean.AndRestriction(*set().union(*problems.values()))
                 match = self.find_best_match(combined, pkgset)
                 yield match, set(problems.keys())
-            except ValueError:
+            except (ValueError, IndexError):
                 results: dict[package, set[str]] = defaultdict(set)
                 for keyword, deps in problems.items():
                     match = self.find_best_match(deps, pkgset)
@@ -310,6 +322,8 @@ class DependencyGraph:
             dot.write("\trankdir=LR;\n")
             for node in self.nodes:
                 node_text = "\\n".join(node.lines())
+                if node.bugno is not None:
+                    node_text += f"\\nbug #{node.bugno}"
                 dot.write(f'\t{node.dot_edge}[label="{node_text}"];\n')
                 for other in node.edges:
                     dot.write(f"\t{node.dot_edge} -> {other.dot_edge};\n")
@@ -385,6 +399,46 @@ class DependencyGraph:
                 found_someone = True
                 break
 
+    def scan_existing_bugs(self, api_key: str):
+        params = urlencode(
+            {
+                "Bugzilla_api_key": api_key,
+                "include_fields": "id,cf_stabilisation_atoms",
+                "component": "Stabilization",
+                "resolution": "---",
+                "f1": "cf_stabilisation_atoms",
+                "o1": "anywords",
+                "v1": {pkg[0].unversioned_atom for node in self.nodes for pkg in node.pkgs},
+            },
+            doseq=True,
+        )
+        request = urllib.Request(
+            url="https://bugs.gentoo.org/rest/bug?" + params,
+            method="GET",
+            headers={
+                "Content-Type": "application/json",
+                "Accept": "application/json",
+            },
+        )
+        with urllib.urlopen(request, timeout=30) as response:
+            reply = json.loads(response.read().decode("utf-8"))
+        for bug in reply["bugs"]:
+            bug_atoms = (
+                parse_atom(line.split(" ", 1)[0]).unversioned_atom
+                for line in map(str.strip, bug["cf_stabilisation_atoms"].splitlines())
+                if line
+            )
+            bug_match = boolean.OrRestriction(*bug_atoms)
+            for node in self.nodes:
+                if node.bugno is None and all(bug_match.match(pkg[0]) for pkg in node.pkgs):
+                    node.bugno = bug["id"]
+                    self.out.write(
+                        self.out.fg("yellow"),
+                        f"Found https://bugs.gentoo.org/{node.bugno} for node {node}",
+                        self.out.reset,
+                    )
+                    break
+
     def file_bugs(self, api_key: str, auto_cc_arches: frozenset[str]):
         def observe(node: GraphNode):
             self.out.write(
@@ -411,6 +465,9 @@ def main(options, out: Formatter, err: Formatter):
     for node in d.nodes:
         node.cleanup_keywords(search_repo)
 
+    if userquery("Check for open bugs matching current graph?", out, err, default_answer=False):
+        d.scan_existing_bugs(options.api_key)
+
     if options.dot is not None:
         d.output_dot(options.dot)
         out.write(out.fg("green"), f"Dot file written to {options.dot}", out.reset)


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-04-20 18:37 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-04-20 18:37 UTC (permalink / raw
  To: gentoo-commits

commit:     43aa314d9f3c7f00b516422cfa8163181399d87e
Author:     Arsen Arsenović <arsen <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 20 10:42:19 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Apr 20 18:33:49 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=43aa314d

pkgdev bugs: Fix spelling of agent noun for 'file'

The agent noun of the verb '(to) file' is 'filer'.
Signed-off-by: Arsen Arsenović <arsen <AT> gentoo.org>
Closes: https://github.com/pkgcore/pkgdev/pull/135
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 4cf726a..173fce8 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -1,4 +1,4 @@
-"""Automatic bugs filler"""
+"""Automatic bugs filer"""
 
 import json
 import urllib.request as urllib


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-04-22 16:16 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-04-22 16:16 UTC (permalink / raw
  To: gentoo-commits

commit:     ada871c510ab618493805b70ef0a1e054b5cbe8a
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 22 16:12:58 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Apr 22 16:15:50 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=ada871c5

bugs: better error message when package not found

Resolves: https://github.com/pkgcore/pkgdev/issues/134
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 173fce8..5b85e52 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -453,10 +453,18 @@ class DependencyGraph:
             node.file_bug(api_key, auto_cc_arches, observe)
 
 
+def _parse_targets(search_repo, targets):
+    for _, target in targets:
+        try:
+            yield max(search_repo.itermatch(target))
+        except ValueError:
+            raise ValueError(f"Restriction {target} has no match in repository")
+
+
 @bugs.bind_main_func
 def main(options, out: Formatter, err: Formatter):
     search_repo = options.search_repo
-    targets = [max(search_repo.itermatch(target)) for _, target in options.targets]
+    targets = list(_parse_targets(search_repo, options.targets))
     d = DependencyGraph(out, err, options)
     d.build_full_graph(targets)
     d.merge_cycles()


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-04-22 16:32 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-04-22 16:32 UTC (permalink / raw
  To: gentoo-commits

commit:     a691a6cca142370e3790a879bf0f05961b76a8c0
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 22 16:32:10 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Apr 22 16:32:10 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=a691a6cc

bugs: fix restriction passing to find_best_match

Resolves: https://github.com/pkgcore/pkgdev/issues/131
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 5b85e52..4a7f34c 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -250,7 +250,7 @@ class DependencyGraph:
 
     def find_best_match(self, restrict, pkgset: list[package]) -> package:
         restrict = boolean.AndRestriction(
-            restrict,
+            *restrict,
             packages.PackageRestriction("properties", values.ContainmentMatch("live", negate=True)),
         )
         # prefer using already selected packages in graph
@@ -276,13 +276,21 @@ class DependencyGraph:
         for pkgname, problems in issues.items():
             pkgset: list[package] = self.options.repo.match(atom(pkgname))
             try:
-                combined = boolean.AndRestriction(*set().union(*problems.values()))
-                match = self.find_best_match(combined, pkgset)
+                match = self.find_best_match(set().union(*problems.values()), pkgset)
                 yield match, set(problems.keys())
             except (ValueError, IndexError):
                 results: dict[package, set[str]] = defaultdict(set)
                 for keyword, deps in problems.items():
-                    match = self.find_best_match(deps, pkgset)
+                    try:
+                        match = self.find_best_match(deps, pkgset)
+                    except (ValueError, IndexError):
+                        deps_str = " , ".join(map(str, deps))
+                        self.err.write(
+                            self.err.fg("red"),
+                            f"unable to find match for restrictions: {deps_str}",
+                            self.err.reset,
+                        )
+                        raise
                     results[match].add(keyword)
                 yield from results.items()
 


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-04-22 16:56 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-04-22 16:56 UTC (permalink / raw
  To: gentoo-commits

commit:     1d12cafe86c5bb9806b043513b84292205131e83
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 22 16:53:37 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Apr 22 16:53:37 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=1d12cafe

bugs: support piping package list from stdin

When calling the tool without packages (for example just `pkgdev bugs`),
and you pipe (from a file or another command) a list of packages, it
will read the package list and use it.

The input file can have empty lines, and comments. Everything after the
first # is considered a comment. Whitespaces are stripped.

Resolves: https://github.com/pkgcore/pkgdev/issues/136
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 4a7f34c..98d84f9 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -1,6 +1,7 @@
 """Automatic bugs filer"""
 
 import json
+import sys
 import urllib.request as urllib
 from collections import defaultdict
 from functools import partial
@@ -19,7 +20,7 @@ from pkgcore.ebuild.misc import sort_keywords
 from pkgcore.repository import multiplex
 from pkgcore.restrictions import boolean, packages, values
 from pkgcore.test.misc import FakePkg
-from pkgcore.util import commandline
+from pkgcore.util import commandline, parserestrict
 from snakeoil.cli import arghparse
 from snakeoil.cli.input import userquery
 from snakeoil.formatters import Formatter
@@ -47,7 +48,7 @@ bugs.add_argument(
 bugs.add_argument(
     "targets",
     metavar="target",
-    nargs="+",
+    nargs="*",
     action=commandline.StoreTarget,
     help="extended atom matching of packages",
 )
@@ -285,10 +286,8 @@ class DependencyGraph:
                         match = self.find_best_match(deps, pkgset)
                     except (ValueError, IndexError):
                         deps_str = " , ".join(map(str, deps))
-                        self.err.write(
-                            self.err.fg("red"),
+                        self.err.error(
                             f"unable to find match for restrictions: {deps_str}",
-                            self.err.reset,
                         )
                         raise
                     results[match].add(keyword)
@@ -461,6 +460,18 @@ class DependencyGraph:
             node.file_bug(api_key, auto_cc_arches, observe)
 
 
+def _load_from_stdin(out: Formatter, err: Formatter):
+    if not sys.stdin.isatty():
+        out.warn("No packages were specified, reading from stdin...")
+        for line in sys.stdin.readlines():
+            if line := line.split("#", 1)[0].strip():
+                yield line, parserestrict.parse_match(line)
+        # reassign stdin to allow interactivity (currently only works for unix)
+        sys.stdin = open("/dev/tty")
+    else:
+        raise arghparse.ArgumentError(None, "reading from stdin is only valid when piping data in")
+
+
 def _parse_targets(search_repo, targets):
     for _, target in targets:
         try:
@@ -472,6 +483,7 @@ def _parse_targets(search_repo, targets):
 @bugs.bind_main_func
 def main(options, out: Formatter, err: Formatter):
     search_repo = options.search_repo
+    options.targets = options.targets or list(_load_from_stdin(out, err))
     targets = list(_parse_targets(search_repo, options.targets))
     d = DependencyGraph(out, err, options)
     d.build_full_graph(targets)


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-05-05 17:49 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-05-05 17:49 UTC (permalink / raw
  To: gentoo-commits

commit:     0a1c70e0f501f6cdda4cef3cd9940c2f5dac8ada
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri May  5 17:49:16 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri May  5 17:49:16 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=0a1c70e0

bugs: fallback to `~/.bugz_token` for api-key

Resolves: https://github.com/pkgcore/pkgdev/issues/138
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 8c79ac6..e2eaf33 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -1,11 +1,13 @@
 """Automatic bugs filer"""
 
+import contextlib
 import json
 import sys
 import urllib.request as urllib
 from collections import defaultdict
 from functools import partial
 from itertools import chain
+from pathlib import Path
 from urllib.parse import urlencode
 
 from pkgcheck import const as pkgcheck_const
@@ -508,6 +510,10 @@ def main(options, out: Formatter, err: Formatter):
     for node in d.nodes:
         node.cleanup_keywords(search_repo)
 
+    if options.api_key is None:
+        with contextlib.suppress(Exception):
+            options.api_key = (Path.home() / ".bugz_token").read_text().strip() or None
+
     if userquery("Check for open bugs matching current graph?", out, err, default_answer=False):
         d.scan_existing_bugs(options.api_key)
 


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-05-28 19:41 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-05-28 19:41 UTC (permalink / raw
  To: gentoo-commits

commit:     049d817f5b2811c8de05342300230d75ce4aa3e8
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun May 28 19:38:30 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun May 28 19:41:32 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=049d817f

bugs: fix wrong blocks_bug arg to deps bugs

When failing, fails with the following exception::

    TypeError: Object of type function is not JSON serializable

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

 src/pkgdev/scripts/pkgdev_bugs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index e2eaf33..25608d6 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -204,7 +204,7 @@ class GraphNode:
             return self.bugno
         for dep in self.edges:
             if dep.bugno is None:
-                dep.file_bug(api_key, auto_cc_arches, observer)
+                dep.file_bug(api_key, auto_cc_arches, (), observer)
         maintainers = dict.fromkeys(
             maintainer.email for pkg, _ in self.pkgs for maintainer in pkg.maintainers
         )


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-06-09 14:21 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-06-09 14:21 UTC (permalink / raw
  To: gentoo-commits

commit:     0c3f492054694f241a3d4a4c99b77151620560d3
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  9 14:18:56 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  9 14:21:28 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=0c3f4920

bugs: fix summary is too long

When there are a lot of atoms in same bug, the summary gets too long and
server responds with Bad Request. For such long titles, shorten it into
one atom and suffix " and friends" (great text from sam)

Resolves: https://github.com/pkgcore/pkgdev/issues/141
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 25608d6..daf4828 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -214,13 +214,17 @@ class GraphNode:
             keywords = []
         maintainers = tuple(maintainers) or ("maintainer-needed@gentoo.org",)
 
+        summary = f"{', '.join(pkg.versioned_atom.cpvstr for pkg, _ in self.pkgs)}: stablereq"
+        if len(summary) > 60:
+            summary = f"{self.pkgs[0][0].versioned_atom.cpvstr} and friends: stablereq"
+
         request_data = dict(
             Bugzilla_api_key=api_key,
             product="Gentoo Linux",
             component="Stabilization",
             severity="enhancement",
             version="unspecified",
-            summary=f"{', '.join(pkg.versioned_atom.cpvstr for pkg, _ in self.pkgs)}: stablereq",
+            summary=summary,
             description="Please stabilize",
             keywords=keywords,
             cf_stabilisation_atoms="\n".join(self.lines()),


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-06-09 16:52 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-06-09 16:52 UTC (permalink / raw
  To: gentoo-commits

commit:     98bbf58de73677d08127b73c89ddef42e6300045
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  9 16:51:58 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  9 16:51:58 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=98bbf58d

bugs: improve output texts

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

 src/pkgdev/scripts/pkgdev_bugs.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index daf4828..0a3ff91 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -215,7 +215,7 @@ class GraphNode:
         maintainers = tuple(maintainers) or ("maintainer-needed@gentoo.org",)
 
         summary = f"{', '.join(pkg.versioned_atom.cpvstr for pkg, _ in self.pkgs)}: stablereq"
-        if len(summary) > 60:
+        if len(summary) > 90 and len(self.pkgs) > 1:
             summary = f"{self.pkgs[0][0].versioned_atom.cpvstr} and friends: stablereq"
 
         request_data = dict(
@@ -473,7 +473,7 @@ class DependencyGraph:
                 f"https://bugs.gentoo.org/{node.bugno} ",
                 " | ".join(node.lines()),
                 " depends on bugs ",
-                {dep.bugno for dep in node.edges},
+                {dep.bugno for dep in node.edges} or "{}",
             )
             self.out.flush()
 


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-06-22 16:16 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-06-22 16:16 UTC (permalink / raw
  To: gentoo-commits

commit:     d8f4c5c7b198d6ad0dc6bfe88163b5ae0cff2b48
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 22 16:16:09 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 22 16:16:09 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=d8f4c5c7

bugs: fix bugs to open count

Resolves: https://github.com/pkgcore/pkgdev/issues/142
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 0a3ff91..08da876 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -525,8 +525,13 @@ def main(options, out: Formatter, err: Formatter):
         d.output_dot(options.dot)
         out.write(out.fg("green"), f"Dot file written to {options.dot}", out.reset)
 
+    bugs_count = len(tuple(node for node in d.nodes if node.bugno is None))
+    if bugs_count == 0:
+        out.write(out.fg("red"), "Nothing to do, exiting", out.reset)
+        return 1
+
     if not userquery(
-        f"Continue and create {len(d.nodes)} stablereq bugs?", out, err, default_answer=False
+        f"Continue and create {bugs_count} stablereq bugs?", out, err, default_answer=False
     ):
         return 1
 


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-09-08 12:13 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-09-08 12:13 UTC (permalink / raw
  To: gentoo-commits

commit:     5a5bd751ad28317cc60754d1e874f82240daa2a1
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Fri Sep  8 07:56:59 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Sep  8 12:12:20 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=5a5bd751

pkgdev_bugs: do not swallow exceptions when reading ~/.bugz_token

In case the file is not readable, or other issues, do not swallow the
exception.

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/pkgcore/pkgdev/pull/158
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 26f77c5..c89d1c8 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -546,8 +546,9 @@ def main(options, out: Formatter, err: Formatter):
         node.cleanup_keywords(search_repo)
 
     if options.api_key is None:
-        with contextlib.suppress(Exception):
-            options.api_key = (Path.home() / ".bugz_token").read_text().strip() or None
+        bugz_token_file = Path.home() / ".bugz_token"
+        if bugz_token_file.is_file:
+            options.api_key = bugz_token_file.read_text().strip()
 
     if not d.nodes:
         out.write(out.fg("red"), "Nothing to do, exiting", out.reset)


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-09-08 12:13 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-09-08 12:13 UTC (permalink / raw
  To: gentoo-commits

commit:     f86b2f6591efb9a147cb6cd6be7e8f5ec3a3065d
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Fri Sep  8 08:01:59 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Sep  8 12:12:42 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=f86b2f65

pkgdev_bugs: add warning about using --api-key, document ~/.bugz_token

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/pkgcore/pkgdev/pull/159
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 0a63077..48eb13d 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -42,7 +42,9 @@ bugs.add_argument(
     metavar="KEY",
     help="Bugzilla API key",
     docs="""
-        The Bugzilla API key to use for authentication.
+        The Bugzilla API key to use for authentication. WARNING: using this
+        option will expose your API key to other users of the same system.
+        Consider instead saving your API key in a file named ~/.bugz_token.
     """,
 )
 bugs.add_argument(


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-09-08 12:13 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-09-08 12:13 UTC (permalink / raw
  To: gentoo-commits

commit:     4e4789fde8afedb974e6584464f36ca2934eb115
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Fri Sep  8 08:00:12 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Sep  8 12:12:42 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=4e4789fd

pkgdev_bugs: remove outdated --api-key description

pkgdev now does perform write access to b.g.o using the API key.

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

 src/pkgdev/scripts/pkgdev_bugs.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index c89d1c8..0a63077 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -42,9 +42,7 @@ bugs.add_argument(
     metavar="KEY",
     help="Bugzilla API key",
     docs="""
-        The Bugzilla API key to use for authentication. Used mainly to overcome
-        rate limiting done by bugzilla server. This tool doesn't perform any
-        bug editing, just fetching info for the bug.
+        The Bugzilla API key to use for authentication.
     """,
 )
 bugs.add_argument(


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-12-15 10:44 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-12-15 10:44 UTC (permalink / raw
  To: gentoo-commits

commit:     cb9e2ad3fa6f4c27bf6613cbb418d952a21e835b
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 15 10:43:56 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 15 10:43:56 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=cb9e2ad3

bugs: print bug summary where existing bug is found

Resolves: https://github.com/pkgcore/pkgdev/issues/163
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 48eb13d..e6cac18 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -458,7 +458,7 @@ class DependencyGraph:
         params = urlencode(
             {
                 "Bugzilla_api_key": api_key,
-                "include_fields": "id,cf_stabilisation_atoms",
+                "include_fields": "id,cf_stabilisation_atoms,summary",
                 "component": "Stabilization",
                 "resolution": "---",
                 "f1": "cf_stabilisation_atoms",
@@ -492,6 +492,7 @@ class DependencyGraph:
                         f"Found https://bugs.gentoo.org/{node.bugno} for node {node}",
                         self.out.reset,
                     )
+                    self.out.write(" -> bug summary: ", bug["summary"])
                     break
 
     def file_bugs(self, api_key: str, auto_cc_arches: frozenset[str], block_bugs: list[int]):


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-12-15 11:42 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-12-15 11:42 UTC (permalink / raw
  To: gentoo-commits

commit:     c9fdcf2edf1f43cde2e8eef1c709ba33c47b5f8a
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 15 11:42:34 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 15 11:42:34 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=c9fdcf2e

bugs: prefer using user selected targets

Resolves: https://github.com/pkgcore/pkgdev/issues/161
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 924e9e4..6f444e9 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -279,6 +279,7 @@ class DependencyGraph:
 
         self.nodes: set[GraphNode] = set()
         self.starting_nodes: set[GraphNode] = set()
+        self.targets: tuple[package] = ()
 
     def mk_fake_pkg(self, pkg: package, keywords: set[str]):
         return FakePkg(
@@ -295,6 +296,9 @@ class DependencyGraph:
             *restrict,
             packages.PackageRestriction("properties", values.ContainmentMatch("live", negate=True)),
         )
+        # prefer using user selected targets
+        if intersect := tuple(filter(restrict.match, self.targets)):
+            return max(intersect)
         # prefer using already selected packages in graph
         all_pkgs = (pkg for node in self.nodes for pkg, _ in node.pkgs)
         if intersect := tuple(filter(restrict.match, all_pkgs)):
@@ -345,6 +349,7 @@ class DependencyGraph:
                 yield from results.items()
 
     def build_full_graph(self, targets: list[package]):
+        self.targets = tuple(targets)
         check_nodes = [(pkg, set()) for pkg in targets]
 
         vertices: dict[package, GraphNode] = {}


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-12-15 19:52 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-12-15 19:52 UTC (permalink / raw
  To: gentoo-commits

commit:     1a8570b79d49c4013dd96697ff246d5c1035941d
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 15 19:51:50 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 15 19:51:50 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=1a8570b7

bugs: merge stable groups as first step

The is no good reason to perform it as last, but as first step it does
work better.

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

 src/pkgdev/scripts/pkgdev_bugs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 6f444e9..a5c28a9 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -564,9 +564,9 @@ def main(options, out: Formatter, err: Formatter):
         options.targets = list(_load_from_stdin(out, err))
     targets = list(_parse_targets(search_repo, options.targets))
     d.build_full_graph(targets)
+    d.merge_stabilization_groups()
     d.merge_cycles()
     d.merge_new_keywords_children()
-    d.merge_stabilization_groups()
 
     for node in d.nodes:
         node.cleanup_keywords(search_repo)


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-12-17  5:44 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-12-17  5:44 UTC (permalink / raw
  To: gentoo-commits

commit:     ee5abb29ef2877d0e4e0b1f183d50578a49b1a26
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 17 05:42:03 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Dec 17 05:42:03 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=ee5abb29

bugs: handle merging of top level nodes

Resolves: https://github.com/pkgcore/pkgdev/issues/125
Resolves: https://github.com/pkgcore/pkgdev/issues/167
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index a5c28a9..5d3672c 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -437,6 +437,7 @@ class DependencyGraph:
             assert starting_node in self.nodes
             while cycle := self._find_cycles(tuple(self.nodes), [starting_node]):
                 self.out.write("Found cycle: ", " -> ".join(str(n) for n in cycle))
+                start_nodes.difference_update(cycle)
                 new_node = self.merge_nodes(cycle)
                 if starting_node not in self.nodes:
                     starting_node = new_node


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-12-22 13:28 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-12-22 13:28 UTC (permalink / raw
  To: gentoo-commits

commit:     272b9fabe7bfba705c6bfbbdfff901535f1d305b
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 22 13:27:16 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Dec 22 13:27:16 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=272b9fab

bugs: support ~/.bugzrc fir api-key extraction

Resolves: https://github.com/pkgcore/pkgdev/issues/162
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/argparsers.py  | 39 +++++++++++++++++++++++++++++++++++++++
 src/pkgdev/scripts/pkgdev_bugs.py | 18 ++----------------
 src/pkgdev/scripts/pkgdev_tatt.py | 12 ++----------
 3 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/src/pkgdev/scripts/argparsers.py b/src/pkgdev/scripts/argparsers.py
index ac1a758..76479ff 100644
--- a/src/pkgdev/scripts/argparsers.py
+++ b/src/pkgdev/scripts/argparsers.py
@@ -1,5 +1,7 @@
 import os
 import subprocess
+from configparser import ConfigParser
+from pathlib import Path
 
 from pkgcore.repository import errors as repo_errors
 from snakeoil.cli.arghparse import ArgumentParser
@@ -41,3 +43,40 @@ def _determine_git_repo(parser, namespace):
         pass
 
     namespace.git_repo = path
+
+
+class BugzillaApiKey:
+    @classmethod
+    def mangle_argparser(cls, parser):
+        parser.add_argument(
+            "--api-key",
+            metavar="KEY",
+            help="Bugzilla API key",
+            docs="""
+                The Bugzilla API key to use for authentication. WARNING: using this
+                option will expose your API key to other users of the same system.
+                Consider instead saving your API key in a file named ``~/.bugzrc``
+                in an INI format like so::
+
+                        [default]
+                        key = <your API key>
+
+                ANother supported option is to save your API key in a file named
+                ``~/.bugz_token``.
+            """,
+        )
+
+        parser.bind_delayed_default(1000, "api_key")(cls._default_api_key)
+
+    @staticmethod
+    def _default_api_key(namespace, attr):
+        """Use all known arches by default."""
+        if (bugz_rc_file := Path.home() / ".bugzrc").is_file():
+            try:
+                config = ConfigParser(default_section="default")
+                config.read(bugz_rc_file)
+                setattr(namespace, attr, config.get("default", "key"))
+            except Exception as e:
+                raise ValueError(f"failed parsing {bugz_rc_file}: {e}")
+        elif (bugz_token_file := Path.home() / ".bugz_token").is_file():
+            setattr(namespace, attr, bugz_token_file.read_text().strip())

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 5d3672c..7c11d31 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -30,7 +30,7 @@ from snakeoil.cli.input import userquery
 from snakeoil.formatters import Formatter
 
 from ..cli import ArgumentParser
-from .argparsers import _determine_cwd_repo, cwd_repo_argparser
+from .argparsers import _determine_cwd_repo, cwd_repo_argparser, BugzillaApiKey
 
 bugs = ArgumentParser(
     prog="pkgdev bugs",
@@ -39,16 +39,7 @@ bugs = ArgumentParser(
     quiet=False,
     parents=(cwd_repo_argparser,),
 )
-bugs.add_argument(
-    "--api-key",
-    metavar="KEY",
-    help="Bugzilla API key",
-    docs="""
-        The Bugzilla API key to use for authentication. WARNING: using this
-        option will expose your API key to other users of the same system.
-        Consider instead saving your API key in a file named ~/.bugz_token.
-    """,
-)
+BugzillaApiKey.mangle_argparser(bugs)
 bugs.add_argument(
     "targets",
     metavar="target",
@@ -572,11 +563,6 @@ def main(options, out: Formatter, err: Formatter):
     for node in d.nodes:
         node.cleanup_keywords(search_repo)
 
-    if options.api_key is None:
-        bugz_token_file = Path.home() / ".bugz_token"
-        if bugz_token_file.is_file:
-            options.api_key = bugz_token_file.read_text().strip()
-
     if not d.nodes:
         out.write(out.fg("red"), "Nothing to do, exiting", out.reset)
         return 1

diff --git a/src/pkgdev/scripts/pkgdev_tatt.py b/src/pkgdev/scripts/pkgdev_tatt.py
index 37454fc..79624cd 100644
--- a/src/pkgdev/scripts/pkgdev_tatt.py
+++ b/src/pkgdev/scripts/pkgdev_tatt.py
@@ -15,18 +15,10 @@ from pkgcore.util import packages as pkgutils
 from snakeoil.cli import arghparse
 
 from ..cli import ArgumentParser
+from .argparsers import BugzillaApiKey
 
 tatt = ArgumentParser(prog="pkgdev tatt", description=__doc__, verbose=False, quiet=False)
-tatt.add_argument(
-    "--api-key",
-    metavar="KEY",
-    help="Bugzilla API key",
-    docs="""
-        The Bugzilla API key to use for authentication. Used mainly to overcome
-        rate limiting done by bugzilla server. This tool doesn't perform any
-        bug editing, just fetching info for the bug.
-    """,
-)
+BugzillaApiKey.mangle_argparser(tatt)
 tatt.add_argument(
     "-j",
     "--job-name",


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-12-30 10:45 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-12-30 10:45 UTC (permalink / raw
  To: gentoo-commits

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

bugs: improve best match finder

Use ``find_best_match`` for finding the best match, for the targets list
(instead of just selecting the max for each target). Apply this for
stabilization groups and cmd line packages. We do need to opt out the
preference for semi-stable over non-stable, as we want to stabilize
those requested.

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

 src/pkgdev/scripts/pkgdev_bugs.py | 42 +++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 7c11d31..21f242f 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -8,7 +8,6 @@ from collections import defaultdict
 from datetime import datetime
 from functools import partial
 from itertools import chain
-from pathlib import Path
 from urllib.parse import urlencode
 
 from pkgcheck import const as pkgcheck_const
@@ -282,7 +281,7 @@ class DependencyGraph:
             data={attr: str(getattr(pkg, attr.lower())) for attr in pkg.eapi.dep_keys},
         )
 
-    def find_best_match(self, restrict, pkgset: list[package]) -> package:
+    def find_best_match(self, restrict, pkgset: list[package], prefer_semi_stable=True) -> package:
         restrict = boolean.AndRestriction(
             *restrict,
             packages.PackageRestriction("properties", values.ContainmentMatch("live", negate=True)),
@@ -295,18 +294,18 @@ class DependencyGraph:
         if intersect := tuple(filter(restrict.match, all_pkgs)):
             return max(intersect)
         matches = sorted(filter(restrict.match, pkgset), reverse=True)
-        for match in matches:
-            if not all(keyword.startswith("~") for keyword in match.keywords):
-                return match
+        if prefer_semi_stable:
+            for match in matches:
+                if not all(keyword.startswith("~") for keyword in match.keywords):
+                    return match
         return matches[0]
 
     def extend_targets_stable_groups(self, groups):
         stabilization_groups = self.options.repo.stabilization_groups
-        search_repo = self.options.search_repo
         for group in groups:
             for pkg in stabilization_groups[group]:
                 try:
-                    yield None, self.find_best_match([pkg], search_repo.match(pkg)).versioned_atom
+                    yield None, pkg
                 except (ValueError, IndexError):
                     self.err.write(f"Unable to find match for {pkg.unversioned_atom}")
 
@@ -339,9 +338,18 @@ class DependencyGraph:
                     results[match].add(keyword)
                 yield from results.items()
 
-    def build_full_graph(self, targets: list[package]):
-        self.targets = tuple(targets)
-        check_nodes = [(pkg, set()) for pkg in targets]
+    def load_targets(self, targets: list[tuple[str, str]]):
+        result = []
+        search_repo = self.options.search_repo
+        for _, target in targets:
+            try:
+                result.append(self.find_best_match([target], search_repo.match(target), False))
+            except ValueError:
+                raise ValueError(f"Restriction {target} has no match in repository")
+        self.targets = tuple(result)
+
+    def build_full_graph(self):
+        check_nodes = [(pkg, set()) for pkg in self.targets]
 
         vertices: dict[package, GraphNode] = {}
         edges = []
@@ -373,7 +381,7 @@ class DependencyGraph:
         for src, dst in edges:
             vertices[src].edges.add(vertices[dst])
         self.starting_nodes = {
-            vertices[starting_node] for starting_node in targets if starting_node in vertices
+            vertices[starting_node] for starting_node in self.targets if starting_node in vertices
         }
 
     def output_dot(self, dot_file):
@@ -538,14 +546,6 @@ def _load_from_stdin(out: Formatter, err: Formatter):
         raise arghparse.ArgumentError(None, "reading from stdin is only valid when piping data in")
 
 
-def _parse_targets(search_repo, targets):
-    for _, target in targets:
-        try:
-            yield max(search_repo.itermatch(target))
-        except ValueError:
-            raise ValueError(f"Restriction {target} has no match in repository")
-
-
 @bugs.bind_main_func
 def main(options, out: Formatter, err: Formatter):
     search_repo = options.search_repo
@@ -554,8 +554,8 @@ def main(options, out: Formatter, err: Formatter):
     options.targets.extend(d.extend_targets_stable_groups(options.sets or ()))
     if not options.targets:
         options.targets = list(_load_from_stdin(out, err))
-    targets = list(_parse_targets(search_repo, options.targets))
-    d.build_full_graph(targets)
+    d.load_targets(options.targets)
+    d.build_full_graph()
     d.merge_stabilization_groups()
     d.merge_cycles()
     d.merge_new_keywords_children()


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-12-30 13:08 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-12-30 13:08 UTC (permalink / raw
  To: gentoo-commits

commit:     d12a4a8f647e2db7a0d88a4bc17766e652ebba36
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 30 13:08:33 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Dec 30 13:08:33 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=d12a4a8f

bugs: improve error output

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

 src/pkgdev/scripts/pkgdev_bugs.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 1a5cd0d..0909390 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -406,10 +406,10 @@ class DependencyGraph:
                         match = self.find_best_match(deps, pkgset)
                     except (ValueError, IndexError):
                         deps_str = " , ".join(map(str, deps))
-                        self.err.error(
+                        bugs.error(
                             f"unable to find match for restrictions: {deps_str}",
+                            status=3,
                         )
-                        raise
                     results[match].add(keyword)
                 yield from results.items()
 
@@ -427,8 +427,8 @@ class DependencyGraph:
                     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")
+            except (ValueError, IndexError):
+                bugs.error(f"Restriction {target} has no match in repository", status=3)
         self.targets = tuple(result)
 
     def build_full_graph(self):
@@ -617,7 +617,7 @@ class DependencyGraph:
             node.file_bug(api_key, auto_cc_arches, block_bugs, modified_repo, observe)
 
 
-def _load_from_stdin(out: Formatter, err: Formatter):
+def _load_from_stdin(out: Formatter):
     if not sys.stdin.isatty():
         out.warn("No packages were specified, reading from stdin...")
         for line in sys.stdin.readlines():
@@ -626,7 +626,7 @@ def _load_from_stdin(out: Formatter, err: Formatter):
         # reassign stdin to allow interactivity (currently only works for unix)
         sys.stdin = open("/dev/tty")
     else:
-        raise arghparse.ArgumentError(None, "reading from stdin is only valid when piping data in")
+        bugs.error("reading from stdin is only valid when piping data in")
 
 
 @bugs.bind_main_func
@@ -637,7 +637,7 @@ def main(options, out: Formatter, err: Formatter):
     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))
+        options.targets = list(_load_from_stdin(out))
     d.load_targets(options.targets)
     d.build_full_graph()
     d.merge_stabilization_groups()


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2023-12-30 13:37 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2023-12-30 13:37 UTC (permalink / raw
  To: gentoo-commits

commit:     45e2a7c1d0ce8e9ef7bba0cae4b4648a5d764540
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 30 13:37:35 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Dec 30 13:37:35 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=45e2a7c1

argparse: better handling of ~/.bugzrc

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

 src/pkgdev/scripts/argparsers.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/pkgdev/scripts/argparsers.py b/src/pkgdev/scripts/argparsers.py
index 5cefeca..9ab58da 100644
--- a/src/pkgdev/scripts/argparsers.py
+++ b/src/pkgdev/scripts/argparsers.py
@@ -1,6 +1,7 @@
 import os
 import subprocess
 from configparser import ConfigParser
+from contextlib import suppress
 from pathlib import Path
 
 from pkgcore.repository import errors as repo_errors
@@ -75,8 +76,13 @@ class BugzillaApiKey:
             try:
                 config = ConfigParser(default_section="default")
                 config.read(bugz_rc_file)
-                setattr(namespace, attr, config.get("default", "key"))
             except Exception as e:
                 raise ValueError(f"failed parsing {bugz_rc_file}: {e}")
-        elif (bugz_token_file := Path.home() / ".bugz_token").is_file():
+
+            for category in ("default", "gentoo", "Gentoo"):
+                with suppress(Exception):
+                    setattr(namespace, attr, config.get(category, "key"))
+                    return
+
+        if (bugz_token_file := Path.home() / ".bugz_token").is_file():
             setattr(namespace, attr, bugz_token_file.read_text().strip())


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2024-01-23 20:47 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2024-01-23 20:47 UTC (permalink / raw
  To: gentoo-commits

commit:     8ef6cce1f01f3bba4ad4b6ac74552b8310ef1bea
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 23 20:45:05 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 23 20:47:07 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=8ef6cce1

bugs: implement edit resulting graph before filing

Relates: https://github.com/pkgcore/pkgdev/issues/169
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 166 +++++++++++++++++++++++++++++++++-----
 1 file changed, 146 insertions(+), 20 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 0909390..75ae274 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -2,7 +2,11 @@
 
 import contextlib
 import json
+import os
+import shlex
+import subprocess
 import sys
+import tempfile
 import urllib.request as urllib
 from collections import defaultdict
 from datetime import datetime
@@ -13,7 +17,7 @@ from urllib.parse import urlencode
 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.addons.git import GitAddon, GitAddedRepo, GitModifiedRepo
 from pkgcheck.checks import visibility, stablereq
 from pkgcheck.scripts import argparse_actions
 from pkgcore.ebuild.atom import atom
@@ -34,6 +38,11 @@ from snakeoil.osutils import pjoin
 from ..cli import ArgumentParser
 from .argparsers import _determine_cwd_repo, cwd_repo_argparser, BugzillaApiKey
 
+if sys.version_info >= (3, 11):
+    import tomllib
+else:
+    import tomli as tomllib
+
 bugs = ArgumentParser(
     prog="pkgdev bugs",
     description=__doc__,
@@ -54,6 +63,17 @@ bugs.add_argument(
     "--dot",
     help="path file where to save the graph in dot format",
 )
+bugs.add_argument(
+    "--edit-graph",
+    action="store_true",
+    help="open editor to modify the graph before filing bugs",
+    docs="""
+        When this argument is passed, pkgdev will open the graph in the editor
+        (either ``$VISUAL`` or ``$EDITOR``) before filing bugs. The graph is
+        represented in TOML format. After saving and exiting the editor, the
+        tool would use the graph from the file to file bugs.
+    """,
+)
 bugs.add_argument(
     "--auto-cc-arches",
     action=arghparse.CommaSeparatedNegationsAppend,
@@ -192,12 +212,14 @@ def parse_atom(pkg: str):
 
 
 class GraphNode:
-    __slots__ = ("pkgs", "edges", "bugno")
+    __slots__ = ("pkgs", "edges", "bugno", "summary", "cc_arches")
 
     def __init__(self, pkgs: tuple[tuple[package, set[str]], ...], bugno=None):
         self.pkgs = pkgs
         self.edges: set[GraphNode] = set()
         self.bugno = bugno
+        self.summary = ""
+        self.cc_arches = None
 
     def __eq__(self, __o: object):
         return self is __o
@@ -217,6 +239,8 @@ class GraphNode:
 
     @property
     def dot_edge(self):
+        if self.bugno is not None:
+            return f"bug_{self.bugno}"
         return f'"{self.pkgs[0][0].versioned_atom}"'
 
     def cleanup_keywords(self, repo):
@@ -234,6 +258,29 @@ class GraphNode:
                 keywords.clear()
                 keywords.add("*")
 
+    @property
+    def bug_summary(self):
+        if self.summary:
+            return self.summary
+        summary = f"{', '.join(pkg.versioned_atom.cpvstr for pkg, _ in self.pkgs)}: stablereq"
+        if len(summary) > 90 and len(self.pkgs) > 1:
+            return f"{self.pkgs[0][0].versioned_atom.cpvstr} and friends: stablereq"
+        return summary
+
+    @property
+    def node_maintainers(self):
+        return dict.fromkeys(
+            maintainer.email for pkg, _ in self.pkgs for maintainer in pkg.maintainers
+        )
+
+    def should_cc_arches(self, auto_cc_arches: frozenset[str]):
+        if self.cc_arches is not None:
+            return self.cc_arches
+        maintainers = self.node_maintainers
+        return bool(
+            not maintainers or "*" in auto_cc_arches or auto_cc_arches.intersection(maintainers)
+        )
+
     def file_bug(
         self,
         api_key: str,
@@ -247,28 +294,22 @@ class GraphNode:
         for dep in self.edges:
             if dep.bugno is None:
                 dep.file_bug(api_key, auto_cc_arches, (), modified_repo, observer)
-        maintainers = dict.fromkeys(
-            maintainer.email for pkg, _ in self.pkgs for maintainer in pkg.maintainers
-        )
-        if not maintainers or "*" in auto_cc_arches or auto_cc_arches.intersection(maintainers):
+        maintainers = self.node_maintainers
+        if self.should_cc_arches(auto_cc_arches):
             keywords = ["CC-ARCHES"]
         else:
             keywords = []
         maintainers = tuple(maintainers) or ("maintainer-needed@gentoo.org",)
 
-        summary = f"{', '.join(pkg.versioned_atom.cpvstr for pkg, _ in self.pkgs)}: stablereq"
-        if len(summary) > 90 and len(self.pkgs) > 1:
-            summary = f"{self.pkgs[0][0].versioned_atom.cpvstr} and friends: stablereq"
-
         description = ["Please stabilize", ""]
         if modified_repo is not None:
             for pkg, _ in self.pkgs:
                 with contextlib.suppress(StopIteration):
                     match = next(modified_repo.itermatch(pkg.versioned_atom))
-                    added = datetime.fromtimestamp(match.time)
-                    days_old = (datetime.today() - added).days
+                    modified = datetime.fromtimestamp(match.time)
+                    days_old = (datetime.today() - modified).days
                     description.append(
-                        f" {pkg.versioned_atom.cpvstr}: no change for {days_old} days, since {added:%Y-%m-%d}"
+                        f" {pkg.versioned_atom.cpvstr}: no change for {days_old} days, since {modified:%Y-%m-%d}"
                     )
 
         request_data = dict(
@@ -277,7 +318,7 @@ class GraphNode:
             component="Stabilization",
             severity="enhancement",
             version="unspecified",
-            summary=summary,
+            summary=self.bug_summary,
             description="\n".join(description).strip(),
             keywords=keywords,
             cf_stabilisation_atoms="\n".join(self.lines()),
@@ -308,6 +349,8 @@ class DependencyGraph:
         self.out = out
         self.err = err
         self.options = options
+        disabled, enabled = options.auto_cc_arches
+        self.auto_cc_arches = frozenset(enabled).difference(disabled)
         self.profile_addon: ProfileAddon = init_addon(ProfileAddon, options)
 
         self.nodes: set[GraphNode] = set()
@@ -315,6 +358,8 @@ class DependencyGraph:
         self.targets: tuple[package] = ()
 
         git_addon = init_addon(GitAddon, options)
+        self.added_repo = git_addon.cached_repo(GitAddedRepo)
+        self.modified_repo = git_addon.cached_repo(GitModifiedRepo)
         self.stablereq_check = stablereq.StableRequestCheck(self.options, git_addon=git_addon)
 
     def mk_fake_pkg(self, pkg: package, keywords: set[str]):
@@ -467,7 +512,7 @@ class DependencyGraph:
             vertices[starting_node] for starting_node in self.targets if starting_node in vertices
         }
 
-    def output_dot(self, dot_file):
+    def output_dot(self, dot_file: str):
         with open(dot_file, "w") as dot:
             dot.write("digraph {\n")
             dot.write("\trankdir=LR;\n")
@@ -481,6 +526,67 @@ class DependencyGraph:
             dot.write("}\n")
             dot.close()
 
+    def output_graph_toml(self):
+        self.auto_cc_arches
+        bugs = dict(enumerate(self.nodes, start=1))
+        reverse_bugs = {node: bugno for bugno, node in bugs.items()}
+
+        toml = tempfile.NamedTemporaryFile(mode="w", suffix=".toml")
+        for bugno, node in bugs.items():
+            if node.bugno is not None:
+                continue  # already filed
+            toml.write(f"[bug-{bugno}]\n")
+            toml.write(f'summary = "{node.bug_summary}"\n')
+            toml.write(f"cc_arches = {str(node.should_cc_arches(self.auto_cc_arches)).lower()}\n")
+            if node_depends := ", ".join(
+                (f'"bug-{reverse_bugs[dep]}"' if dep.bugno is None else str(dep.bugno))
+                for dep in node.edges
+            ):
+                toml.write(f"depends = [{node_depends}]\n")
+            if node_blocks := ", ".join(
+                f'"bug-{i}"' for i, src in bugs.items() if node in src.edges
+            ):
+                toml.write(f"blocks = [{node_blocks}]\n")
+            for pkg, arches in node.pkgs:
+                match = next(self.modified_repo.itermatch(pkg.versioned_atom))
+                modified = datetime.fromtimestamp(match.time)
+                match = next(self.added_repo.itermatch(pkg.versioned_atom))
+                added = datetime.fromtimestamp(match.time)
+                toml.write(
+                    f"# added on {added:%Y-%m-%d} (age {(datetime.today() - added).days} days), last modified on {modified:%Y-%m-%d} (age {(datetime.today() - modified).days} days)\n"
+                )
+                keywords = ", ".join(f'"{x}"' for x in sort_keywords(arches))
+                toml.write(f'"{pkg.versioned_atom}" = [{keywords}]\n')
+            toml.write("\n\n")
+        toml.flush()
+        return toml
+
+    def load_graph_toml(self, toml_file: str):
+        repo = self.options.search_repo
+        with open(toml_file, "rb") as f:
+            data = tomllib.load(f)
+
+        new_bugs: dict[int | str, GraphNode] = {}
+        for node_name, data_node in data.items():
+            pkgs = tuple(
+                (next(repo.itermatch(atom(pkg))), set(keywords))
+                for pkg, keywords in data_node.items()
+                if pkg.startswith("=")
+            )
+            new_bugs[node_name] = GraphNode(pkgs)
+        for node_name, data_node in data.items():
+            new_bugs[node_name].summary = data_node.get("summary", "")
+            new_bugs[node_name].cc_arches = data_node.get("cc_arches", None)
+            for dep in data_node.get("depends", ()):
+                if isinstance(dep, int):
+                    new_bugs[node_name].edges.add(new_bugs.setdefault(dep, GraphNode((), dep)))
+                elif new_bugs.get(dep) is not None:
+                    new_bugs[node_name].edges.add(new_bugs[dep])
+                else:
+                    bugs.error(f"[{node_name}]['depends']: unknown dependency {dep!r}")
+        self.nodes = set(new_bugs.values())
+        self.starting_nodes = {node for node in self.nodes if not node.edges}
+
     def merge_nodes(self, nodes: tuple[GraphNode, ...]) -> GraphNode:
         self.nodes.difference_update(nodes)
         is_start = bool(self.starting_nodes.intersection(nodes))
@@ -612,9 +718,8 @@ class DependencyGraph:
             )
             self.out.flush()
 
-        modified_repo = init_addon(GitAddon, self.options).cached_repo(GitModifiedRepo)
         for node in self.starting_nodes:
-            node.file_bug(api_key, auto_cc_arches, block_bugs, modified_repo, observe)
+            node.file_bug(api_key, auto_cc_arches, block_bugs, self.modified_repo, observe)
 
 
 def _load_from_stdin(out: Formatter):
@@ -644,9 +749,6 @@ def main(options, out: Formatter, err: Formatter):
     d.merge_cycles()
     d.merge_new_keywords_children()
 
-    for node in d.nodes:
-        node.cleanup_keywords(search_repo)
-
     if not d.nodes:
         out.write(out.fg("red"), "Nothing to do, exiting", out.reset)
         return 1
@@ -654,9 +756,33 @@ def main(options, out: Formatter, err: Formatter):
     if userquery("Check for open bugs matching current graph?", out, err, default_answer=False):
         d.scan_existing_bugs(options.api_key)
 
+    if options.edit_graph:
+        toml = d.output_graph_toml()
+
+    for node in d.nodes:
+        node.cleanup_keywords(search_repo)
+
     if options.dot is not None:
         d.output_dot(options.dot)
         out.write(out.fg("green"), f"Dot file written to {options.dot}", out.reset)
+        out.flush()
+
+    if options.edit_graph:
+        editor = shlex.split(os.environ.get("VISUAL", os.environ.get("EDITOR", "nano")))
+        try:
+            subprocess.run(editor + [toml.name], check=True)
+        except subprocess.CalledProcessError:
+            bugs.error("failed writing mask comment")
+        except FileNotFoundError:
+            bugs.error(f"nonexistent editor: {editor[0]!r}")
+        d.load_graph_toml(toml.name)
+        for node in d.nodes:
+            node.cleanup_keywords(search_repo)
+
+        if options.dot is not None:
+            d.output_dot(options.dot)
+            out.write(out.fg("green"), f"Dot file written to {options.dot}", out.reset)
+            out.flush()
 
     bugs_count = len(tuple(node for node in d.nodes if node.bugno is None))
     if bugs_count == 0:


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2024-01-25 16:01 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2024-01-25 16:01 UTC (permalink / raw
  To: gentoo-commits

commit:     68de4d0eaa6d95c1692320b01da5f5328ac770e9
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 25 16:00:19 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Jan 25 16:00:19 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=68de4d0e

bugs: indicate why dependent packages are added

Resolves: https://github.com/pkgcore/pkgdev/issues/170
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_bugs.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 75ae274..86f5247 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -477,12 +477,12 @@ class DependencyGraph:
         self.targets = tuple(result)
 
     def build_full_graph(self):
-        check_nodes = [(pkg, set()) for pkg in self.targets]
+        check_nodes = [(pkg, set(), "") for pkg in self.targets]
 
         vertices: dict[package, GraphNode] = {}
         edges = []
         while len(check_nodes):
-            pkg, keywords = check_nodes.pop(0)
+            pkg, keywords, reason = check_nodes.pop(0)
             if pkg in vertices:
                 vertices[pkg].pkgs[0][1].update(keywords)
                 continue
@@ -497,14 +497,16 @@ class DependencyGraph:
             ), f"no keywords for {pkg.versioned_atom}, currently unsupported by tool: https://github.com/pkgcore/pkgdev/issues/123"
             self.nodes.add(new_node := GraphNode(((pkg, keywords),)))
             vertices[pkg] = new_node
+            if reason:
+                reason = f" [added for {reason}]"
             self.out.write(
-                f"Checking {pkg.versioned_atom} on {' '.join(sort_keywords(keywords))!r}"
+                f"Checking {pkg.versioned_atom} on {' '.join(sort_keywords(keywords))!r}{reason}"
             )
             self.out.flush()
 
             for dep, keywords in self._find_dependencies(pkg, keywords):
                 edges.append((pkg, dep))
-                check_nodes.append((dep, keywords))
+                check_nodes.append((dep, keywords, str(pkg.versioned_atom)))
 
         for src, dst in edges:
             vertices[src].edges.add(vertices[dst])


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2024-02-26 20:48 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2024-02-26 20:48 UTC (permalink / raw
  To: gentoo-commits

commit:     16a22e29ec16f0013a94ff3f26f10b6a15626b57
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 26 20:48:42 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Feb 26 20:48:42 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=16a22e29

bugs: don't crash when atom not found in history

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

 src/pkgdev/scripts/pkgdev_bugs.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 86f5247..6864ba7 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -550,13 +550,23 @@ class DependencyGraph:
             ):
                 toml.write(f"blocks = [{node_blocks}]\n")
             for pkg, arches in node.pkgs:
-                match = next(self.modified_repo.itermatch(pkg.versioned_atom))
-                modified = datetime.fromtimestamp(match.time)
-                match = next(self.added_repo.itermatch(pkg.versioned_atom))
-                added = datetime.fromtimestamp(match.time)
-                toml.write(
-                    f"# added on {added:%Y-%m-%d} (age {(datetime.today() - added).days} days), last modified on {modified:%Y-%m-%d} (age {(datetime.today() - modified).days} days)\n"
-                )
+                try:
+                    match = next(self.modified_repo.itermatch(pkg.versioned_atom))
+                    modified = datetime.fromtimestamp(match.time)
+                    age = (datetime.today() - modified).days
+                    modified_text = f"{modified:%Y-%m-%d} (age {age} days)"
+                except StopIteration:
+                    modified_text = "<unknown>"
+
+                try:
+                    match = next(self.added_repo.itermatch(pkg.versioned_atom))
+                    added = datetime.fromtimestamp(match.time)
+                    age = (datetime.today() - added).days
+                    added_text = f"{added:%Y-%m-%d} (age {age} days)"
+                except StopIteration:
+                    added_text = "<unknown>"
+
+                toml.write(f"# added on {added_text}, last modified on {modified_text}\n")
                 keywords = ", ".join(f'"{x}"' for x in sort_keywords(arches))
                 toml.write(f'"{pkg.versioned_atom}" = [{keywords}]\n')
             toml.write("\n\n")


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2024-03-12 19:38 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2024-03-12 19:38 UTC (permalink / raw
  To: gentoo-commits

commit:     d3ca0833690ec26f5ddcb0d3157fc85c69dc8d5e
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 12 19:34:51 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Mar 12 19:34:51 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=d3ca0833

tatt: fix required_use for packages from bug

When invoked on bug's package list, we use nattka to find matches in the
repo. Nattka requires configured repo, which we were passing beforehand.
But this results in a case where we have a configured packages, without
source ebuild's "required_use" (it was "configured" by the domain).

While somewhat ugly, fix it by performing a second iteration, this time
over the source repo, and get the expected package object we can use.

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

 src/pkgdev/scripts/pkgdev_tatt.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_tatt.py b/src/pkgdev/scripts/pkgdev_tatt.py
index 79624cd..ff88d25 100644
--- a/src/pkgdev/scripts/pkgdev_tatt.py
+++ b/src/pkgdev/scripts/pkgdev_tatt.py
@@ -234,9 +234,9 @@ def _get_bugzilla_packages(namespace):
     bug = next(iter(nattka_bugzilla.find_bugs(bugs=[namespace.bug]).values()))
     namespace.keywording = bug.category == BugCategory.KEYWORDREQ
     repo = namespace.domain.repos["gentoo"].raw_repo
-    return dict(
-        match_package_list(repo, bug, only_new=True, filter_arch=[namespace.domain.arch])
-    ).keys()
+    src_repo = namespace.domain.source_repos_raw
+    for pkg, _ in match_package_list(repo, bug, only_new=True, filter_arch=[namespace.domain.arch]):
+        yield src_repo.match(pkg.versioned_atom)[0]
 
 
 def _get_cmd_packages(namespace):


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2024-03-12 19:49 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2024-03-12 19:49 UTC (permalink / raw
  To: gentoo-commits

commit:     e1646fa6ccf350b3dd030ca52208db1c458344c9
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 12 19:48:46 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Mar 12 19:48:46 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=e1646fa6

tatt: test run should be after the use combinations

Resolves: https://github.com/pkgcore/pkgdev/issues/174
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_tatt.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_tatt.py b/src/pkgdev/scripts/pkgdev_tatt.py
index ff88d25..5a76b54 100644
--- a/src/pkgdev/scripts/pkgdev_tatt.py
+++ b/src/pkgdev/scripts/pkgdev_tatt.py
@@ -314,12 +314,12 @@ def _build_job(namespace, pkg, is_test: bool):
 
 def _build_jobs(namespace, pkgs):
     for pkg in pkgs:
-        if namespace.test and "test" in pkg.defined_phases:
-            yield pkg.versioned_atom, True, next(iter(_build_job(namespace, pkg, True)))
-
         for flags in islice(_build_job(namespace, pkg, False), namespace.use_combos):
             yield pkg.versioned_atom, False, flags
 
+        if namespace.test and "test" in pkg.defined_phases:
+            yield pkg.versioned_atom, True, next(iter(_build_job(namespace, pkg, True)))
+
 
 def _create_config_dir(directory: Path):
     if not directory.exists():


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2024-05-31 11:13 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2024-05-31 11:13 UTC (permalink / raw
  To: gentoo-commits

commit:     e9f38cd0ce2b1eda130634f8569f5521c2c6511d
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri May 31 11:13:08 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri May 31 11:13:08 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=e9f38cd0

mask: support comma separated bugs

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

 src/pkgdev/scripts/pkgdev_mask.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_mask.py b/src/pkgdev/scripts/pkgdev_mask.py
index 041eef1..1d614a0 100644
--- a/src/pkgdev/scripts/pkgdev_mask.py
+++ b/src/pkgdev/scripts/pkgdev_mask.py
@@ -61,9 +61,10 @@ mask_opts.add_argument(
 mask_opts.add_argument(
     "-b",
     "--bug",
+    "--bugs",
     dest="bugs",
-    action="append",
-    type=arghparse.positive_int,
+    action=arghparse.CommaSeparatedValuesAppend,
+    default=[],
     help="reference bug in the mask comment",
     docs="""
         Add a reference to a bug in the mask comment. May be specified multiple
@@ -100,6 +101,8 @@ def _mask_validate(parser, namespace):
     atoms = set()
     maintainers = set()
 
+    namespace.bugs = list(map(int, dict.fromkeys(namespace.bugs)))
+
     if not namespace.rites and namespace.file_bug:
         mask.error("bug filing requires last rites")
     if namespace.file_bug and not namespace.api_key:


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2024-06-12 10:35 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2024-06-12 10:35 UTC (permalink / raw
  To: gentoo-commits

commit:     63bd3b696bcc2a32ab5fa2448f98b6b9817d5ba8
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 12 10:35:12 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 12 10:35:12 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=63bd3b69

mask: support filing bugs with no dependent bugs

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

 src/pkgdev/scripts/pkgdev_mask.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/pkgdev/scripts/pkgdev_mask.py b/src/pkgdev/scripts/pkgdev_mask.py
index 450c52c..d1d2249 100644
--- a/src/pkgdev/scripts/pkgdev_mask.py
+++ b/src/pkgdev/scripts/pkgdev_mask.py
@@ -328,6 +328,8 @@ def file_last_rites_bug(options, message: str) -> int:
 
 
 def update_bugs_pmasked(api_key: str, bugs: list[int]):
+    if not bugs:
+        return True
     request_data = dict(
         Bugzilla_api_key=api_key,
         ids=bugs,


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

* [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/
@ 2024-07-20 15:37 Arthur Zamarin
  0 siblings, 0 replies; 37+ messages in thread
From: Arthur Zamarin @ 2024-07-20 15:37 UTC (permalink / raw
  To: gentoo-commits

commit:     530d4faa9f61242138c67f634967f981e5c5a5c1
Author:     Lucio Sauer <watermanpaint <AT> posteo <DOT> net>
AuthorDate: Sat Jul 20 14:44:22 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Jul 20 15:37:19 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=530d4faa

pkgdev commit: add optional support for Closes tags with resolution

Support resolutions FIXED, OBSOLETE and PKGREMOVED, provided that the
bug belongs to b.g.o.  The default and fallback resolution is FIXED.

Together with server-side changes to
https://gitweb.gentoo.org/infra/githooks.git/, this patch allows Gentoo
contributors to generate commit tags that cause bugs to be closed
automatically with the indicated resolution.

Currently, only the string after the last colon in the argument is
significant for the resolution.  Therefore, one could theoretically
craft invalid tags such as
'Closes: https://bugs.gentoo.org/123:foo (obsolete)'

Signed-off-by: Lucio Sauer <watermanpaint <AT> posteo.net>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgdev/scripts/pkgdev_commit.py | 51 +++++++++++++++++++++++++++++++++++--
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/pkgdev/scripts/pkgdev_commit.py b/src/pkgdev/scripts/pkgdev_commit.py
index dc4d46f..77a21f0 100644
--- a/src/pkgdev/scripts/pkgdev_commit.py
+++ b/src/pkgdev/scripts/pkgdev_commit.py
@@ -10,6 +10,7 @@ import tempfile
 import textwrap
 from collections import defaultdict, deque, UserDict
 from dataclasses import dataclass
+from enum import Enum
 from functools import partial
 from itertools import chain
 
@@ -57,13 +58,17 @@ class ArgumentParser(cli.ArgumentParser):
 class BugTag(argparse.Action):
     """Register bug-related tag to inject into the commit message footer."""
 
-    def __call__(self, parser, namespace, value, option_string=None):
+    def parse_url(self, value):
         try:
             url = f"https://bugs.gentoo.org/{int(value)}"
         except ValueError:
             url = value
             if not url.startswith(("https://", "http://")):
                 raise argparse.ArgumentError(self, f"invalid URL: {url}")
+        return url
+
+    def __call__(self, parser, namespace, value, option_string=None):
+        url = self.parse_url(value)
         namespace.footer.add((self.dest.capitalize(), url))
 
 
@@ -80,6 +85,39 @@ class CommitTag(argparse.Action):
         namespace.footer.add((name.capitalize(), val))
 
 
+class BugzillaAwareBugTag(BugTag):
+    """Register bug-related tag and resolution to inject into the commit message footer."""
+
+    class Resolution(Enum):
+        FIXED = "fixed"
+        OBSOLETE = "obsolete"
+        PKGREMOVED = "pkgremoved"
+
+    def __call__(self, parser, namespace, values, option_string=None):
+        has_resolution = False
+        try:
+            bug, val = values.rsplit(":", 1)
+            if not bug:
+                raise argparse.ArgumentError(self, f"invalid commit tag: {values!r}")
+            if not val.startswith("//"):
+                has_resolution = True
+                res = self.Resolution(val.lower()) if val else self.Resolution.FIXED
+        except ValueError:
+            if has_resolution:
+                err = f"{val!r} should be one of: {', '.join([m.value for m in self.Resolution])}"
+                raise argparse.ArgumentError(self, err)
+
+        if not has_resolution:
+            super().__call__(parser, namespace, values, option_string)
+            return
+        url = self.parse_url(bug)
+        is_bgo = "bugs.gentoo.org" in url
+        if is_bgo and not res is self.Resolution.FIXED:
+            url = f"{url} ({res.value})"
+
+        namespace.footer.add((self.dest.capitalize(), url))
+
+
 commit = ArgumentParser(
     prog="pkgdev commit",
     description="create git commit",
@@ -92,7 +130,16 @@ commit_opts.add_argument(
     "-b", "--bug", action=BugTag, help="add Bug tag for a given Gentoo or upstream bug"
 )
 commit_opts.add_argument(
-    "-c", "--closes", action=BugTag, help="add Closes tag for a given Gentoo bug or upstream PR URL"
+    "-c",
+    "--closes",
+    action=BugzillaAwareBugTag,
+    metavar="CLOSES[:RESOLUTION]",
+    help="add Closes tag and optionally a resolution for a given Gentoo bug or upstream PR URL",
+    docs="""
+        Indicate that a bug or PR may be closed. The optional resolution string
+        for Gentoo's Bugzilla describes what happened to a bug. It is
+        case-insensitive and must be one of FIXED, OBSOLETE or PKGREMOVED.
+    """,
 )
 commit_opts.add_argument(
     "-T", "--tag", action=CommitTag, metavar="NAME:VALUE", help="add commit tag"


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

end of thread, other threads:[~2024-07-20 15:37 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-30 13:08 [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/ Arthur Zamarin
  -- strict thread matches above, loose matches on Subject: below --
2024-07-20 15:37 Arthur Zamarin
2024-06-12 10:35 Arthur Zamarin
2024-05-31 11:13 Arthur Zamarin
2024-03-12 19:49 Arthur Zamarin
2024-03-12 19:38 Arthur Zamarin
2024-02-26 20:48 Arthur Zamarin
2024-01-25 16:01 Arthur Zamarin
2024-01-23 20:47 Arthur Zamarin
2023-12-30 13:37 Arthur Zamarin
2023-12-30 10:45 Arthur Zamarin
2023-12-22 13:28 Arthur Zamarin
2023-12-17  5:44 Arthur Zamarin
2023-12-15 19:52 Arthur Zamarin
2023-12-15 11:42 Arthur Zamarin
2023-12-15 10:44 Arthur Zamarin
2023-09-08 12:13 Arthur Zamarin
2023-09-08 12:13 Arthur Zamarin
2023-09-08 12:13 Arthur Zamarin
2023-06-22 16:16 Arthur Zamarin
2023-06-09 16:52 Arthur Zamarin
2023-06-09 14:21 Arthur Zamarin
2023-05-28 19:41 Arthur Zamarin
2023-05-05 17:49 Arthur Zamarin
2023-04-22 16:56 Arthur Zamarin
2023-04-22 16:32 Arthur Zamarin
2023-04-22 16:16 Arthur Zamarin
2023-04-20 18:37 Arthur Zamarin
2023-03-27 18:38 Arthur Zamarin
2023-03-18 18:20 Arthur Zamarin
2023-03-11 16:07 Arthur Zamarin
2023-03-05 19:55 Arthur Zamarin
2023-03-04 15:05 Arthur Zamarin
2023-01-13 21:39 Arthur Zamarin
2023-01-13 21:07 Arthur Zamarin
2022-11-19 12:51 Arthur Zamarin
2022-10-04  8:03 Arthur Zamarin

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