Skip to content

Commit

Permalink
Support swift package.resolved v3
Browse files Browse the repository at this point in the history
Signed-off-by: jiyeong.seok <[email protected]>
  • Loading branch information
dd-jy committed Oct 9, 2024
1 parent 76946f2 commit fc10cdc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/fosslight_dependency/_package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def version_refine(oss_version):


def connect_github(github_token):
if github_token is not None:
if len(github_token) > 0:
g = Github(github_token)
else:
g = Github()
Expand Down
11 changes: 6 additions & 5 deletions src/fosslight_dependency/package_manager/Swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def parse_dep_tree_json(self, rel_json):
return ret

def parse_oss_information(self, f_name):
json_ver = 1
json_ver = 2
purl_dict = {}

with open(f_name, 'r', encoding='utf8') as json_file:
Expand All @@ -107,11 +107,12 @@ def parse_oss_information(self, f_name):

if json_ver == 1:
json_data = json_raw["object"]["pins"]
elif json_ver == 2:
elif json_ver == 2 or json_ver == 3:
json_data = json_raw["pins"]
else:
logger.error(f'Not supported Package.resolved version {json_ver}')
return
logger.warning(f'Not supported Package.resolved version {json_ver}')
logger.warning(f'Try to parse as version 2(or 3)')
json_data = json_raw["pins"]

g = connect_github(self.github_token)

Expand All @@ -121,7 +122,7 @@ def parse_oss_information(self, f_name):
if json_ver == 1:
oss_origin_name = key['package']
oss_item.homepage = key['repositoryURL']
elif json_ver == 2:
else:
oss_origin_name = key['identity']
oss_item.homepage = key['location']

Expand Down

0 comments on commit fc10cdc

Please sign in to comment.