Skip to content

Commit 290143b

Browse files
committed
bugs: mention age of packages in the bug description
Resolves: #140 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent cb9e2ad commit 290143b

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

src/pkgdev/scripts/pkgdev_bugs.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import urllib.request as urllib
77
from collections import defaultdict
8+
from datetime import datetime
89
from functools import partial
910
from itertools import chain
1011
from pathlib import Path
@@ -13,6 +14,7 @@
1314
from pkgcheck import const as pkgcheck_const
1415
from pkgcheck.addons import ArchesAddon, init_addon
1516
from pkgcheck.addons.profiles import ProfileAddon
17+
from pkgcheck.addons.git import GitAddon, GitModifiedRepo
1618
from pkgcheck.checks import visibility
1719
from pkgcheck.scripts import argparse_actions
1820
from pkgcore.ebuild.atom import atom
@@ -113,6 +115,7 @@
113115
)
114116

115117
ArchesAddon.mangle_argparser(bugs)
118+
GitAddon.mangle_argparser(bugs)
116119
ProfileAddon.mangle_argparser(bugs)
117120

118121

@@ -199,13 +202,18 @@ def cleanup_keywords(self, repo):
199202
keywords.add("*")
200203

201204
def file_bug(
202-
self, api_key: str, auto_cc_arches: frozenset[str], block_bugs: list[int], observer=None
205+
self,
206+
api_key: str,
207+
auto_cc_arches: frozenset[str],
208+
block_bugs: list[int],
209+
modified_repo: multiplex.tree,
210+
observer=None,
203211
) -> int:
204212
if self.bugno is not None:
205213
return self.bugno
206214
for dep in self.edges:
207215
if dep.bugno is None:
208-
dep.file_bug(api_key, auto_cc_arches, (), observer)
216+
dep.file_bug(api_key, auto_cc_arches, (), modified_repo, observer)
209217
maintainers = dict.fromkeys(
210218
maintainer.email for pkg, _ in self.pkgs for maintainer in pkg.maintainers
211219
)
@@ -219,14 +227,25 @@ def file_bug(
219227
if len(summary) > 90 and len(self.pkgs) > 1:
220228
summary = f"{self.pkgs[0][0].versioned_atom.cpvstr} and friends: stablereq"
221229

230+
description = ["Please stabilize", ""]
231+
if modified_repo is not None:
232+
for pkg, _ in self.pkgs:
233+
with contextlib.suppress(StopIteration):
234+
match = next(modified_repo.itermatch(pkg.versioned_atom))
235+
added = datetime.fromtimestamp(match.time)
236+
days_old = (datetime.today() - added).days
237+
description.append(
238+
f" {pkg.versioned_atom.cpvstr}: no change for {days_old} days, since {added:%Y-%m-%d}"
239+
)
240+
222241
request_data = dict(
223242
Bugzilla_api_key=api_key,
224243
product="Gentoo Linux",
225244
component="Stabilization",
226245
severity="enhancement",
227246
version="unspecified",
228247
summary=summary,
229-
description="Please stabilize",
248+
description="\n".join(description).strip(),
230249
keywords=keywords,
231250
cf_stabilisation_atoms="\n".join(self.lines()),
232251
assigned_to=maintainers[0],
@@ -505,8 +524,9 @@ def observe(node: GraphNode):
505524
)
506525
self.out.flush()
507526

527+
modified_repo = init_addon(GitAddon, self.options).cached_repo(GitModifiedRepo)
508528
for node in self.starting_nodes:
509-
node.file_bug(api_key, auto_cc_arches, block_bugs, observe)
529+
node.file_bug(api_key, auto_cc_arches, block_bugs, modified_repo, observe)
510530

511531

512532
def _load_from_stdin(out: Formatter, err: Formatter):

tests/scripts/test_pkgdev_bugs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_bug_filing(self, repo):
6868
session = BugsSession()
6969
pkg = max(repo.itermatch(atom("=cat/u-0")))
7070
with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session):
71-
bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), ())
71+
bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), (), None)
7272
assert len(session.calls) == 1
7373
call = session.calls[0]
7474
assert call["Bugzilla_api_key"] == "API"
@@ -83,7 +83,7 @@ def test_bug_filing_maintainer_needed(self, repo):
8383
session = BugsSession()
8484
pkg = max(repo.itermatch(atom("=cat/z-0")))
8585
with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session):
86-
bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), ())
86+
bugs.GraphNode(((pkg, {"*"}),)).file_bug("API", frozenset(), (), None)
8787
assert len(session.calls) == 1
8888
call = session.calls[0]
8989
assert call["assigned_to"] == "maintainer-needed@gentoo.org"
@@ -99,7 +99,7 @@ def test_bug_filing_multiple_pkgs(self, repo):
9999
node = bugs.GraphNode(((pkgX, {"*"}), (pkgY, {"*"}), (pkgZ, {"*"})))
100100
node.edges.add(dep)
101101
with patch("pkgdev.scripts.pkgdev_bugs.urllib.urlopen", session):
102-
node.file_bug("API", frozenset(), ())
102+
node.file_bug("API", frozenset(), (), None)
103103
assert len(session.calls) == 1
104104
call = session.calls[0]
105105
assert call["summary"] == "cat/x-0, cat/y-0, cat/z-0: stablereq"

0 commit comments

Comments
 (0)