From 92f4d519a2848253503773d6d05744d1ae0b3565 Mon Sep 17 00:00:00 2001 From: Ben Selwyn-Smith Date: Wed, 4 Dec 2024 14:55:10 +1000 Subject: [PATCH] chore: minor fix Signed-off-by: Ben Selwyn-Smith --- src/macaron/repo_finder/repo_finder_java.py | 10 +++++----- .../cases/repo_finder_remote_calls/repo_finder.py | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/macaron/repo_finder/repo_finder_java.py b/src/macaron/repo_finder/repo_finder_java.py index 8d106d1ea..e6f349d3b 100644 --- a/src/macaron/repo_finder/repo_finder_java.py +++ b/src/macaron/repo_finder/repo_finder_java.py @@ -52,13 +52,13 @@ def find_repo(self, purl: PackageURL) -> str: if not version: logger.info("Version missing for maven artifact: %s:%s", group, artifact) - purl = DepsDevRepoFinder().get_latest_version(purl) - if not purl.version: + latest_purl = DepsDevRepoFinder().get_latest_version(purl) + if not latest_purl or not latest_purl.version: logger.debug("Could not find version for artifact: %s:%s", purl.namespace, purl.name) return "" - group = purl.namespace or "" - artifact = purl.name - version = purl.version + group = latest_purl.namespace or "" + artifact = latest_purl.name + version = latest_purl.version while group and artifact and version and limit > 0: # Create the URLs for retrieving the artifact's POM diff --git a/tests/integration/cases/repo_finder_remote_calls/repo_finder.py b/tests/integration/cases/repo_finder_remote_calls/repo_finder.py index 16de2c7d5..f529cb771 100644 --- a/tests/integration/cases/repo_finder_remote_calls/repo_finder.py +++ b/tests/integration/cases/repo_finder_remote_calls/repo_finder.py @@ -71,12 +71,13 @@ def test_repo_finder() -> int: if not parsed_url or not repo_validator.resolve_redirects(parsed_url): return os.EX_UNAVAILABLE - # Test Java package whose SCM metadata only points to the repo in the later versions than is provided here. + # Test Java package whose SCM metadata only points to the repo in later versions than is provided here. purl = PackageURL.from_string("pkg:maven/io.vertx/vertx-auth-common@3.8.0") repo = find_repo(purl) if repo == "https://github.com/eclipse-vertx/vertx-auth": return os.EX_UNAVAILABLE latest_purl = DepsDevRepoFinder().get_latest_version(purl) + assert latest_purl repo = find_repo(latest_purl) if repo != "https://github.com/eclipse-vertx/vertx-auth": return os.EX_UNAVAILABLE