Skip to content

Commit 07872fd

Browse files
authored
Merge pull request #84 from fosslight/swift_issue
Support Package.resolved v2
2 parents 64f6383 + 8329d7c commit 07872fd

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed

.github/workflows/pull-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ jobs:
100100
fosslight_dependency -p tests/test_pub -o tests/result/pub
101101
fosslight_dependency -p tests/test_cocoapods/cocoapods-tips/JWSCocoapodsTips -o tests/result/Cocoapods
102102
fosslight_dependency -p tests/test_swift -o tests/result/swift -t ${{ secrets.TOKEN }}
103+
fosslight_dependency -p tests/test_swift2 -o tests/result/swift2 -t ${{ secrets.TOKEN }}
103104
fosslight_dependency -p tests/test_carthage -o tests/result/carthage -t ${{ secrets.TOKEN }}
104105
reuse:
105106
runs-on: ubuntu-latest

.reuse/dep5

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@ License: Apache-2.0
8989
Files: tests/test_multi_pypi_npm/*
9090
Copyright: 2021 LG Electronics
9191
License: Apache-2.0
92+
93+
Files: tests/test_swift2/*
94+
Copyright: 2022 LG Electronics
95+
License: Apache-2.0

src/fosslight_dependency/package_manager/Swift.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,34 @@ def check_input_file_path(self):
4040
logger.info(f"It uses the manifest file: {self.input_file_name}")
4141

4242
def parse_oss_information(self, f_name):
43+
sheet_list = []
44+
json_ver = 1
45+
4346
with open(f_name, 'r', encoding='utf8') as json_file:
4447
json_raw = json.load(json_file)
45-
json_data = json_raw["object"]["pins"]
48+
json_ver = json_raw['version']
4649

47-
sheet_list = []
50+
if json_ver == 1:
51+
json_data = json_raw["object"]["pins"]
52+
elif json_ver == 2:
53+
json_data = json_raw["pins"]
54+
else:
55+
logger.error(f'Not supported Package.resolved version {json_ver}')
56+
return sheet_list
4857

4958
g = connect_github(self.github_token)
5059

5160
for key in json_data:
52-
oss_origin_name = key['package']
61+
if json_ver == 1:
62+
oss_origin_name = key['package']
63+
homepage = key['repositoryURL']
64+
elif json_ver == 2:
65+
oss_origin_name = key['identity']
66+
homepage = key['location']
67+
68+
if homepage.endswith('.git'):
69+
homepage = homepage[:-4]
70+
5371
oss_name = f"{self.package_manager_name}:{oss_origin_name}"
5472

5573
revision = key['state']['revision']
@@ -59,7 +77,6 @@ def parse_oss_information(self, f_name):
5977
else:
6078
oss_version = version
6179

62-
homepage = key['repositoryURL']
6380
dn_loc = homepage
6481
license_name = ''
6582

tests/test_swift2/Package.resolved

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)