From 4a8684f286d075f7e091e26f30cda1cd7d10947d Mon Sep 17 00:00:00 2001 From: Ali Zulfiqar Date: Sat, 5 Sep 2026 22:13:57 +0500 Subject: [PATCH 1/2] Match CocoaPods names exactly when reading version lists Signed-off-by: Ali Zulfiqar --- src/fetchcode/package_util.py | 2 +- tests/test_cocoapods_tag_lookup.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/test_cocoapods_tag_lookup.py diff --git a/src/fetchcode/package_util.py b/src/fetchcode/package_util.py index 5284b85..618a21e 100644 --- a/src/fetchcode/package_util.py +++ b/src/fetchcode/package_util.py @@ -297,7 +297,7 @@ def get_cocoapod_tags(spec, name): data = response.strip() for line in data.splitlines(): line = line.strip() - if line.startswith(name): + if line.startswith(name + "/"): data_list = line.split("/") if data_list[0] == name: data_list.pop(0) diff --git a/tests/test_cocoapods_tag_lookup.py b/tests/test_cocoapods_tag_lookup.py new file mode 100644 index 0000000..c138a65 --- /dev/null +++ b/tests/test_cocoapods_tag_lookup.py @@ -0,0 +1,13 @@ +from fetchcode.package_util import get_cocoapod_tags + + +def test_cocoapod_tags_skip_packages_with_same_prefix(monkeypatch): + monkeypatch.setattr( + "fetchcode.utils.get_text_response", lambda url: "FooBar/9.0\nFoo/1.0/2.0\n" + ) + assert get_cocoapod_tags("https://example.com/versions", "Foo") == ["1.0", "2.0"] + + +def test_cocoapod_tags_return_none_when_only_prefix_matches(monkeypatch): + monkeypatch.setattr("fetchcode.utils.get_text_response", lambda url: "FooBar/9.0\n") + assert get_cocoapod_tags("https://example.com/versions", "Foo") is None From 8f5c6f34600e27caabcbf1e375691781e102d6e8 Mon Sep 17 00:00:00 2001 From: Ali Zulfiqar Date: Sat, 5 Sep 2026 22:30:57 +0500 Subject: [PATCH 2/2] Address review feedback and strengthen regression coverage Signed-off-by: Ali Zulfiqar --- tests/test_cocoapods_tag_lookup.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_cocoapods_tag_lookup.py b/tests/test_cocoapods_tag_lookup.py index c138a65..d16255e 100644 --- a/tests/test_cocoapods_tag_lookup.py +++ b/tests/test_cocoapods_tag_lookup.py @@ -1,3 +1,19 @@ +# fetchcode is a free software tool from nexB Inc. and others. +# Visit https://github.com/aboutcode-org/fetchcode for support and download. + +# Copyright (c) nexB Inc. and others. All rights reserved. +# http://nexb.com and http://aboutcode.org + +# This software is licensed under the Apache License version 2.0. + +# You may not use this software except in compliance with the License. +# You may obtain a copy of the License at: +# http://apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + from fetchcode.package_util import get_cocoapod_tags