From aeb1213432f2fbc5572f126ff72d97ae5d029fe6 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Thu, 2 Jul 2026 17:31:21 +0200 Subject: [PATCH 1/3] Drop unused variables --- zeekpkg/manager.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/zeekpkg/manager.py b/zeekpkg/manager.py index 1601a13..a6822af 100644 --- a/zeekpkg/manager.py +++ b/zeekpkg/manager.py @@ -1140,11 +1140,8 @@ def _refresh_source( agg_adds = [] agg_mods = [] - agg_dels = [] for index_file in source.package_index_files(): - urls = [] - with open(index_file) as f: urls = [line.rstrip("\n") for line in f] From 99f800ceecd3ccaeca05bdc06f5a6f5adc5d669c Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Thu, 2 Jul 2026 16:42:46 +0200 Subject: [PATCH 2/3] Drop unnecessary shared state We previously reused the same variable `status` to store different values without really sharing them. This made the code harder to follow, so this patch just gets rid of that sharing. --- zeekpkg/manager.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/zeekpkg/manager.py b/zeekpkg/manager.py index a6822af..a11cd8c 100644 --- a/zeekpkg/manager.py +++ b/zeekpkg/manager.py @@ -1894,22 +1894,24 @@ def info( ipkg = self.find_installed_package(pkg_path) - status: PackageStatus | None = None if prefer_installed and ipkg: - status = ipkg.status pkg_name = ipkg.package.name clonepath = os.path.join(self.package_clonedir, pkg_name) clone = git.Repo(clonepath) - return _info_from_clone(clone, ipkg.package, status, status.current_version) + return _info_from_clone( + clone, + ipkg.package, + ipkg.status, + ipkg.status.current_version, + ) - status = None matches = self.match_source_packages(pkg_path) if not matches: package = Package(git_url=pkg_path) try: - return self._info(package, status, version, update_submodules) + return self._info(package, None, version, update_submodules) except git.GitCommandError as error: LOG.info( 'getting info on "%s": invalid git repo path: %s', @@ -1923,7 +1925,7 @@ def info( " not a usable git URL (invalid or inaccessible," " use -vvv for details)" ) - return PackageInfo(package=package, invalid_reason=reason, status=status) + return PackageInfo(package=package, invalid_reason=reason, status=None) if len(matches) > 1: matches_string = [match.qualified_name() for match in matches] @@ -1942,11 +1944,11 @@ def info( package = matches[0] try: - return self._info(package, status, version, update_submodules) + return self._info(package, None, version, update_submodules) except git.GitCommandError as error: LOG.info('getting info on "%s": invalid git repo path: %s', pkg_path, error) reason = "git repository is either invalid or unreachable" - return PackageInfo(package=package, invalid_reason=reason, status=status) + return PackageInfo(package=package, invalid_reason=reason, status=None) def _info( self, From c3db68b72fcdd8cba2acca10f18715e16dc8d390 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Thu, 16 Jul 2026 17:10:24 +0200 Subject: [PATCH 3/3] Rework `tests.info-submodules` to avoid reaching out to the internet This test was hardcoding the URI of a supposedly non-existent repo on github.com. This not only caused the test to reach out to the internet just to find nothing, but on some systems it also could have lead to the test hanging while waiting for a user password prompt to unlock their keychain. With this patch we now use an definitely non-existing repo which can be validated without reaching out to expensive external APIs. While touching the file we also fix a mispelling of `git commit` as `gitcommit`; this only failed silently and had no effect on the test outcome since the changes were committed with another `git commit` later. --- testing/tests/info-submodules | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/tests/info-submodules b/testing/tests/info-submodules index ec82de6..54c0774 100644 --- a/testing/tests/info-submodules +++ b/testing/tests/info-submodules @@ -9,10 +9,11 @@ cp zkg.meta clonetest/zkg.meta pushd clonetest -git add zkg.meta && gitcommit -v -m "Update zkg.meta" +git add zkg.meta && git commit -v -m "Update zkg.meta" git submodule add "../$(basename $(realpath .))" -sed 's~url.*$~url = http://github.com/zeek/A-REPO-WHICH-SHOULD-NOT-EXIST~' .gitmodules > modules && mv modules .gitmodules +# Use a full URI so we go through the same Git machinery as a remote repo. +sed 's~url.*$~url = file:///dev/null/A-REPO-WHICH-SHOULD-NOT-EXIST~' .gitmodules > modules && mv modules .gitmodules git add .gitmodules && git commit -v -m 'Add submodule' # @TEST-START-FILE zkg.meta