Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: /, lib/portage/
Date: Mon, 02 Jan 2023 05:26:00
Message-Id: 1672637151.0e56f99b34939bf38dcfc0f9edf43a51f6ccf3fe.sam@gentoo
1 commit: 0e56f99b34939bf38dcfc0f9edf43a51f6ccf3fe
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 2 04:52:54 2023 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 2 05:25:51 2023 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0e56f99b
7
8 news: simplify isRelevant() check
9
10 Hopefully a bit easier to follow now. I'm also not convinced
11 it was right before, as the previous required every restriction.checkRestriction(...)
12 to be true, while the original code only required *one* to be true per
13 restriction.
14
15 Thanks to kurly for noticing a recent news item wasn't showing up.
16
17 Fixes: 9e24d0143450628f334cdb62e579efafd1bfd2ba
18 Fixes: 1ffaa70544f34e93df24c0a175105a900bf272bf
19 Signed-off-by: Sam James <sam <AT> gentoo.org>
20
21 NEWS | 2 ++
22 lib/portage/news.py | 15 ++++++++++-----
23 2 files changed, 12 insertions(+), 5 deletions(-)
24
25 diff --git a/NEWS b/NEWS
26 index 773df02b0..cabd52035 100644
27 --- a/NEWS
28 +++ b/NEWS
29 @@ -5,6 +5,8 @@ Features:
30 * TODO
31
32 Bug fixes:
33 +* news: Fix matching profile paths with Display-If-Profile in some cases.
34 +
35 * checksum: Rewrite Whirlpool implementation as a C extension to substantially improve
36 performance (bug #885909).
37
38
39 diff --git a/lib/portage/news.py b/lib/portage/news.py
40 index 14401814d..f81debe97 100644
41 --- a/lib/portage/news.py
42 +++ b/lib/portage/news.py
43 @@ -279,11 +279,16 @@ class NewsItem:
44
45 kwargs = {"vardb": vardb, "config": config, "profile": profile}
46
47 - all_match = all(
48 - restriction.checkRestriction(**kwargs)
49 - for values in self.restrictions.values()
50 - for restriction in values
51 - )
52 + all_match = True
53 + for values in self.restrictions.values():
54 + matches = [restriction.checkRestriction(**kwargs) for restriction in values]
55 + any_match = any(matches)
56 +
57 + # If, for a single restriction, we didn't match anything, then we obviously
58 + # didn't match everything, so just bail out.
59 + if not any_match:
60 + all_match = False
61 + break
62
63 return all_match