From 3ff1bf473c18b18f47fa5db1177f4c6dcc09d4cd Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Tue, 17 Sep 2024 18:02:24 +0300 Subject: [PATCH] fix: do not treat cached vcs packages as local --- src/ahriman/core/repository/update_handler.py | 2 ++ .../core/repository/test_update_handler.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/ahriman/core/repository/update_handler.py b/src/ahriman/core/repository/update_handler.py index 0c6ee228a..fa58359ec 100644 --- a/src/ahriman/core/repository/update_handler.py +++ b/src/ahriman/core/repository/update_handler.py @@ -153,6 +153,8 @@ def updates_local(self, *, vcs: bool) -> list[Package]: local = packages.get(remote.base) if local is None: continue # we don't add packages automatically + if local.remote.is_remote: + continue # avoid checking AUR packages if local.is_outdated(remote, self.paths, vcs_allowed_age=self.vcs_allowed_age, diff --git a/tests/ahriman/core/repository/test_update_handler.py b/tests/ahriman/core/repository/test_update_handler.py index e82b58060..743fac732 100644 --- a/tests/ahriman/core/repository/test_update_handler.py +++ b/tests/ahriman/core/repository/test_update_handler.py @@ -212,6 +212,7 @@ def test_updates_local(update_handler: UpdateHandler, package_ahriman: Package, """ must check for updates for locally stored packages """ + package_ahriman.remote = RemoteSource(source=PackageSource.Local, git_url="", web_url="", path="", branch="") mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman]) mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)]) fetch_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.fetch") @@ -237,6 +238,7 @@ def test_updates_local_ignore_vcs(update_handler: UpdateHandler, package_ahriman """ must skip VCS packages check if requested for locally stored packages """ + package_ahriman.remote = RemoteSource(source=PackageSource.Local, git_url="", web_url="", path="", branch="") mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman]) mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)]) mocker.patch("ahriman.core.build_tools.sources.Sources.fetch") @@ -263,6 +265,19 @@ def test_updates_local_unknown(update_handler: UpdateHandler, package_ahriman: P assert update_handler.updates_local(vcs=True) == [] +def test_updates_local_remote(update_handler: UpdateHandler, package_ahriman: Package, mocker: MockerFixture) -> None: + """ + must skip packages with remote source + """ + mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman]) + mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)]) + mocker.patch("ahriman.models.package.Package.is_outdated", return_value=True) + mocker.patch("ahriman.core.build_tools.sources.Sources.fetch") + mocker.patch("ahriman.models.package.Package.from_build", return_value=package_ahriman) + + assert update_handler.updates_local(vcs=True) == [] + + def test_updates_local_with_failures(update_handler: UpdateHandler, package_ahriman: Package, mocker: MockerFixture) -> None: """