diff options
author | 2023-12-15 13:20:49 +0200 | |
---|---|---|
committer | 2023-12-15 13:20:49 +0200 | |
commit | 290143b24bab7ccc2f083395e13bd188132b54be (patch) | |
tree | 5e34906ea278c3521145f027e7868fffe56b1b4b | |
parent | bugs: print bug summary where existing bug is found (diff) | |
download | pkgdev-290143b24bab7ccc2f083395e13bd188132b54be.tar.gz pkgdev-290143b24bab7ccc2f083395e13bd188132b54be.tar.bz2 pkgdev-290143b24bab7ccc2f083395e13bd188132b54be.zip |
bugs: mention age of packages in the bug description
Resolves: https://github.com/pkgcore/pkgdev/issues/140
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | src/pkgdev/scripts/pkgdev_bugs.py | 28 | ||||
-rw-r--r-- | tests/scripts/test_pkgdev_bugs.py | 6 |
2 files changed, 27 insertions, 7 deletions
diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py index e6cac18..924e9e4 100644 --- a/src/pkgdev/scripts/pkgdev_bugs.py +++ b/src/pkgdev/scripts/pkgdev_bugs.py @@ -5,6 +5,7 @@ import json import sys import urllib.request as urllib from collections import defaultdict +from datetime import datetime from functools import partial from itertools import chain from pathlib import Path @@ -13,6 +14,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.checks import visibility from pkgcheck.scripts import argparse_actions from pkgcore.ebuild.atom import atom @@ -113,6 +115,7 @@ bugs_state.add_argument( ) ArchesAddon.mangle_argparser(bugs) +GitAddon.mangle_argparser(bugs) ProfileAddon.mangle_argparser(bugs) @@ -199,13 +202,18 @@ class GraphNode: keywords.add("*") def file_bug( - self, api_key: str, auto_cc_arches: frozenset[str], block_bugs: list[int], observer=None + self, + api_key: str, + auto_cc_arches: frozenset[str], + block_bugs: list[int], + modified_repo: multiplex.tree, + observer=None, ) -> int: if self.bugno is not None: 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, (), modified_repo, observer) maintainers = dict.fromkeys( maintainer.email for pkg, _ in self.pkgs for maintainer in pkg.maintainers ) @@ -219,6 +227,17 @@ class GraphNode: 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 + description.append( + f" {pkg.versioned_atom.cpvstr}: no change for {days_old} days, since {added:%Y-%m-%d}" + ) + request_data = dict( Bugzilla_api_key=api_key, product="Gentoo Linux", @@ -226,7 +245,7 @@ class GraphNode: severity="enhancement", version="unspecified", summary=summary, - description="Please stabilize", + description="\n".join(description).strip(), keywords=keywords, cf_stabilisation_atoms="\n".join(self.lines()), assigned_to=maintainers[0], @@ -505,8 +524,9 @@ 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, observe) + node.file_bug(api_key, auto_cc_arches, block_bugs, modified_repo, observe) def _load_from_stdin(out: Formatter, err: Formatter): diff --git a/tests/scripts/test_pkgdev_bugs.py b/tests/scripts/test_pkgdev_bugs.py index e020ffd..641e5f0 100644 --- a/tests/scripts/test_pkgdev_bugs.py +++ b/tests/scripts/test_pkgdev_bugs.py @@ -68,7 +68,7 @@ class TestBugFiling: session = BugsSession() pkg = max(repo.itermatch(atom("=cat/u-0"))) with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session): - bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), ()) + bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), (), None) assert len(session.calls) == 1 call = session.calls[0] assert call["Bugzilla_api_key"] == "API" @@ -83,7 +83,7 @@ class TestBugFiling: session = BugsSession() pkg = max(repo.itermatch(atom("=cat/z-0"))) with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session): - bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), ()) + bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), (), None) assert len(session.calls) == 1 call = session.calls[0] assert call["assigned_to"] == "maintainer-needed@gentoo.org" @@ -99,7 +99,7 @@ class TestBugFiling: node = bugs.GraphNode(((pkgX, {"*"}), (pkgY, {"*"}), (pkgZ, {"*"}))) node.edges.add(dep) with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session): - node.file_bug("API", frozenset(), ()) + node.file_bug("API", frozenset(), (), None) assert len(session.calls) == 1 call = session.calls[0] assert call["summary"] == "cat/x-0, cat/y-0, cat/z-0: stablereq" |