Skip to content

Commit

Permalink
fix: do not treat cached vcs packages as local
Browse files Browse the repository at this point in the history
  • Loading branch information
arcan1s committed Sep 19, 2024
1 parent 50cd71b commit 3ff1bf4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ahriman/core/repository/update_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions tests/ahriman/core/repository/test_update_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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:
"""
Expand Down

0 comments on commit 3ff1bf4

Please sign in to comment.