Skip to content

Commit 65ce766

Browse files
Use CocoaPods source tags without changing package versions
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
1 parent 27c4fc9 commit 65ce766

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

src/fetchcode/package_util.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,8 @@ def construct_cocoapods_package(
362362
if git_url and not http_url:
363363
if git_url.endswith(".git") and git_url.startswith("https://github.com/"):
364364
gh_path = git_url[:-4]
365-
github_tag = source.get("tag")
366-
if github_tag and github_tag.startswith("v"):
367-
tag = github_tag
368-
download_url = f"{gh_path}/archive/refs/tags/{tag}.tar.gz"
365+
github_tag = source.get("tag") or tag
366+
download_url = f"{gh_path}/archive/refs/tags/{github_tag}.tar.gz"
369367
vcs_url = git_url
370368
elif git_url:
371369
vcs_url = git_url
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import pytest
2+
from packageurl import PackageURL
3+
4+
from fetchcode import package_util
5+
6+
7+
@pytest.mark.parametrize("source_tag", ["v1.2.3", "release-1_2_3", None])
8+
def test_cocoapods_source_tag_preserves_package_version(monkeypatch, source_tag):
9+
monkeypatch.setattr(
10+
package_util.utils,
11+
"get_response",
12+
lambda url: {
13+
"source": {"git": "https://github.com/example/Example.git", "tag": source_tag},
14+
},
15+
)
16+
purl = PackageURL(type="cocoapods", name="Example", version="1.2.3")
17+
package = package_util.construct_cocoapods_package(
18+
purl, "Example", "a/b/c", "https://cocoapods.org/pods/Example", None, None, "1.2.3"
19+
)
20+
assert package.version == "1.2.3"
21+
assert (
22+
package.download_url
23+
== f"https://github.com/example/Example/archive/refs/tags/{source_tag or '1.2.3'}.tar.gz"
24+
)

0 commit comments

Comments
 (0)