Skip to content

Commit 4a8684f

Browse files
Match CocoaPods names exactly when reading version lists
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
1 parent 27c4fc9 commit 4a8684f

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/fetchcode/package_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def get_cocoapod_tags(spec, name):
297297
data = response.strip()
298298
for line in data.splitlines():
299299
line = line.strip()
300-
if line.startswith(name):
300+
if line.startswith(name + "/"):
301301
data_list = line.split("/")
302302
if data_list[0] == name:
303303
data_list.pop(0)

tests/test_cocoapods_tag_lookup.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from fetchcode.package_util import get_cocoapod_tags
2+
3+
4+
def test_cocoapod_tags_skip_packages_with_same_prefix(monkeypatch):
5+
monkeypatch.setattr(
6+
"fetchcode.utils.get_text_response", lambda url: "FooBar/9.0\nFoo/1.0/2.0\n"
7+
)
8+
assert get_cocoapod_tags("https://example.com/versions", "Foo") == ["1.0", "2.0"]
9+
10+
11+
def test_cocoapod_tags_return_none_when_only_prefix_matches(monkeypatch):
12+
monkeypatch.setattr("fetchcode.utils.get_text_response", lambda url: "FooBar/9.0\n")
13+
assert get_cocoapod_tags("https://example.com/versions", "Foo") is None

0 commit comments

Comments
 (0)