commit:     861c24ab76bfc36de2ca80a8375866e4123dc51a
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  4 05:56:56 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Mar  4 05:56:56 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=861c24ab

StableRequestCheck: ignore version not keyworded for arches

packages that are not keyworded for relevant arches but keyworded to
another arch, were not ignored by the check. This patch fixes that.

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

 src/pkgcheck/checks/stablereq.py | 5 +++++
 tests/checks/test_stablereq.py   | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/src/pkgcheck/checks/stablereq.py b/src/pkgcheck/checks/stablereq.py
index 57e41a84..be8e2c7f 100644
--- a/src/pkgcheck/checks/stablereq.py
+++ b/src/pkgcheck/checks/stablereq.py
@@ -71,6 +71,7 @@ class StableRequestCheck(GentooRepoCheck):
             pkg_keywords.update(pkg.keywords)
 
         if stable_pkg_keywords := {x for x in pkg_keywords if x[0] not in 
{"-", "~"}}:
+            keyworded_pkg_keywords = {"~" + x for x in stable_pkg_keywords}
             for slot, pkgs in sorted(pkg_slotted.items()):
                 slot_keywords = set().union(*(pkg.keywords for pkg in pkgs))
                 stable_slot_keywords = 
slot_keywords.intersection(stable_pkg_keywords)
@@ -79,6 +80,10 @@ class StableRequestCheck(GentooRepoCheck):
                     if stable_pkg_keywords.intersection(pkg.keywords):
                         break
 
+                    # stop if not keyworded for stable
+                    if not keyworded_pkg_keywords.intersection(pkg.keywords):
+                        break
+
                     try:
                         match = 
next(self.modified_repo.itermatch(pkg.versioned_atom))
                     except StopIteration:

diff --git a/tests/checks/test_stablereq.py b/tests/checks/test_stablereq.py
index 43f4380b..efb94b7a 100644
--- a/tests/checks/test_stablereq.py
+++ b/tests/checks/test_stablereq.py
@@ -118,6 +118,15 @@ class TestStableRequestCheck(ReportTestCase):
         expected = StableRequest("1", ["~amd64"], 30, 
pkg=VersionedCPV("cat/pkg-2"))
         assert r == expected
 
+    def test_unkeyworded_new_pkg(self):
+        self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
+        self.parent_git_repo.add_all("cat/pkg-1")
+        self.parent_repo.create_ebuild("cat/pkg-2", keywords=["~x86"])
+        self.parent_git_repo.add_all("cat/pkg-2")
+        self.child_git_repo.run(["git", "pull", "origin", "main"])
+        self.init_check(future=30)
+        self.assertNoReport(self.check, self.source)
+
     def test_moved_category(self):
         self.parent_repo.create_ebuild("cat/pkg-1", keywords=["amd64"])
         self.parent_git_repo.add_all("cat/pkg-1")

Reply via email to