Skip to content

Commit a411316

Browse files
committed
network: Limit checks to newest versions in slot
Limit network checks to the newest live and non-live versions of every slot of a package. This uses a new LatestVersionRepoSource that is similar to LatestVersionsFilter, except that it is simpler and it actually works for network checks. Closes: #391 Signed-off-by: Michał Górny <mgorny@gentoo.org>
1 parent f3b1533 commit a411316

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/pkgcheck/checks/network.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class RequestError(_RequestException):
9898
class _UrlCheck(NetworkCheck):
9999
"""Generic URL verification check requiring network support."""
100100

101+
_source = sources.LatestVersionRepoSource
102+
101103
known_results = frozenset([
102104
DeadUrl, RedirectedUrl, HttpsUrlAvailable, SSLCertificateError,
103105
])

src/pkgcheck/sources.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from collections import defaultdict, deque
55
from collections.abc import Set
66
from dataclasses import dataclass
7+
from itertools import groupby
78
from operator import attrgetter
89

910
from pkgcore.ebuild.profiles import ProfileError
@@ -59,6 +60,16 @@ def itermatch(self, restrict, sorter=sorted, **kwargs):
5960
return self.source.itermatch(restrict, sorter=sorter, **kwargs)
6061

6162

63+
class LatestVersionRepoSource(RepoSource):
64+
"""Repo source that returns only the latest non-VCS and VCS slots"""
65+
66+
def itermatch(self, *args, **kwargs):
67+
for _, pkgs in groupby(super().itermatch(*args, **kwargs),
68+
key=lambda pkg: pkg.slotted_atom):
69+
best_by_live = {pkg.live: pkg for pkg in pkgs}
70+
yield from sorted(best_by_live.values())
71+
72+
6273
class LatestVersionsFilter:
6374
"""Filter source packages, yielding those from the latest non-VCS and VCS slots."""
6475

0 commit comments

Comments
 (0)