commit:     be92740c59c7dc0309c4e05f2f73ebdf339e2376
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Apr  8 18:17:38 2025 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Apr  8 18:17:38 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=be92740c

BadPackageUpdate: fix when not run inside profiles/ dir

When we weren't inside profiles/ dir, we were running the VisibilityCheck
check. This check was collecting repo.config.updates. This one is cached,
resulting in the value not being recomputed when time comes for
PackageUpdatesCheck to run. This commit fixes this by making sure we
invalidate the cache.

Sadly the object we're using to store config is Immutable, resulting in
a very ugly hack to invalidate the cache, by using the __dict__ attribute
of the object. This is not a good practice, but it works.

Reported-by: Eli Schwartz <eschwartz <AT> gentoo.org>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcheck/checks/repo_metadata.py                                     | 1 +
 .../repos/visibility/PackageUpdatesCheck/BadPackageUpdate/expected.json  | 1 +
 .../repos/visibility/PackageUpdatesCheck/OldPackageUpdate/expected.json  | 1 +
 testdata/repos/visibility/profiles/updates/1Q-2024                       | 1 +
 4 files changed, 4 insertions(+)

diff --git a/src/pkgcheck/checks/repo_metadata.py 
b/src/pkgcheck/checks/repo_metadata.py
index 0e1c7f84..8225abbf 100644
--- a/src/pkgcheck/checks/repo_metadata.py
+++ b/src/pkgcheck/checks/repo_metadata.py
@@ -105,6 +105,7 @@ class PackageUpdatesCheck(RepoCheck):
             base.LogMap("pkgcore.log.logger.error", BadPackageUpdate),
         )
 
+        del self.repo.config.__dict__["_updates"]  # clear cache for immutable 
dict
         # convert log warnings/errors into reports
         with base.LogReports(*logmap) as log_reports:
             repo_updates = self.repo.config.updates

diff --git 
a/testdata/data/repos/visibility/PackageUpdatesCheck/BadPackageUpdate/expected.json
 
b/testdata/data/repos/visibility/PackageUpdatesCheck/BadPackageUpdate/expected.json
new file mode 100644
index 00000000..6af54b91
--- /dev/null
+++ 
b/testdata/data/repos/visibility/PackageUpdatesCheck/BadPackageUpdate/expected.json
@@ -0,0 +1 @@
+{"__class__": "BadPackageUpdate", "msg": "file '1Q-2024': 'move 
<=stub/old-name-1.2.3.4 stub/stable' on line 3: atom <=stub/old-name-1.2.3.4 
must be versionless"}

diff --git 
a/testdata/data/repos/visibility/PackageUpdatesCheck/OldPackageUpdate/expected.json
 
b/testdata/data/repos/visibility/PackageUpdatesCheck/OldPackageUpdate/expected.json
new file mode 100644
index 00000000..4ec693cb
--- /dev/null
+++ 
b/testdata/data/repos/visibility/PackageUpdatesCheck/OldPackageUpdate/expected.json
@@ -0,0 +1 @@
+{"__class__": "OldPackageUpdate", "pkg": "stub/random-pkgname", "updates": 
["move", "VisibilityCheck/OldPackageName", "stub/random-pkgname"]}

diff --git a/testdata/repos/visibility/profiles/updates/1Q-2024 
b/testdata/repos/visibility/profiles/updates/1Q-2024
index dfb9b553..0570b222 100644
--- a/testdata/repos/visibility/profiles/updates/1Q-2024
+++ b/testdata/repos/visibility/profiles/updates/1Q-2024
@@ -1,2 +1,3 @@
 move stub/old-name stub/stable
 move VisibilityCheck/OldPackageName stub/random-pkgname
+move <=stub/old-name-1.2.3.4 stub/stable

Reply via email to