-
-
Notifications
You must be signed in to change notification settings - Fork 616
Fix and enhance support for different bazel metadata versions #4194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
45990c4
bdb908c
8f7875b
658f0d8
454910f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| from collections import defaultdict | ||
|
|
||
| from commoncode import fileutils | ||
| from packageurl import PackageURL | ||
|
|
||
| from licensedcode.cache import build_spdx_license_expression | ||
| from licensedcode.cache import get_cache | ||
|
|
@@ -374,54 +375,27 @@ def parse(cls, location, package_only=True): | |
| ) | ||
| ) | ||
|
|
||
| if ( | ||
| 'upstream_type' | ||
| and 'name' | ||
| and 'version' | ||
| and 'licenses' | ||
| and 'upstream_address' | ||
| in metadata_fields | ||
| ): | ||
| # TODO: Create function that determines package type from download URL, | ||
| # then create a package of that package type from the metadata info | ||
| package_data = dict( | ||
| datasource_id=cls.datasource_id, | ||
| type=metadata_fields.get('upstream_type', cls.default_package_type), | ||
| name=metadata_fields.get('name'), | ||
| version=metadata_fields.get('version'), | ||
| extracted_license_statement=metadata_fields.get('licenses', []), | ||
| parties=parties, | ||
| homepage_url=metadata_fields.get('upstream_address', ''), | ||
| # TODO: Store 'upstream_hash` somewhere | ||
| ) | ||
| yield models.PackageData.from_data(package_data, package_only=True) | ||
|
|
||
| if ( | ||
| 'package_type' | ||
| and 'name' | ||
| and 'version' | ||
| and 'license_expression' | ||
| and 'homepage_url' | ||
| and 'download_url' | ||
| and 'vcs_url' | ||
| and 'download_archive_sha1' | ||
| and 'vcs_commit_hash' | ||
| in metadata_fields | ||
| ): | ||
| package_data = dict( | ||
| datasource_id=cls.datasource_id, | ||
| type=metadata_fields.get('package_type', cls.default_package_type), | ||
| name=metadata_fields.get('name'), | ||
| version=metadata_fields.get('version'), | ||
| extracted_license_statement=metadata_fields.get('license_expression', ''), | ||
| parties=parties, | ||
| homepage_url=metadata_fields.get('homepage_url', ''), | ||
| download_url=metadata_fields.get('download_url', ''), | ||
| vcs_url=metadata_fields.get('vcs_url', ''), | ||
| sha1=metadata_fields.get('download_archive_sha1', ''), | ||
| extra_data=dict(vcs_commit_hash=metadata_fields.get('vcs_commit_hash', '')) | ||
| ) | ||
| yield models.PackageData.from_data(package_data, package_only=True) | ||
| # TODO: Create function that determines package type from download URL, | ||
| # then create a package of that package type from the metadata info | ||
| package_data = dict( | ||
| datasource_id=cls.datasource_id, | ||
| type=metadata_fields.get('upstream_type', metadata_fields.get('package_type', cls.default_package_type)), | ||
| name=metadata_fields.get('name'), | ||
| version=metadata_fields.get('version'), | ||
| extracted_license_statement=metadata_fields.get('licenses', metadata_fields.get('license_expression')), | ||
| parties=parties, | ||
| homepage_url=metadata_fields.get('upstream_address', metadata_fields.get('homepage_url')), | ||
| download_url=metadata_fields.get('download_url'), | ||
| vcs_url=metadata_fields.get('vcs_url'), | ||
| sha1=metadata_fields.get('download_archive_sha1'), | ||
| # TODO: Store 'upstream_hash` somewhere | ||
abraemer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
abraemer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| if 'vcs_commit_hash' in metadata_fields: | ||
| package_data["extra_data"] = dict(vcs_commit_hash=metadata_fields['vcs_commit_hash']) | ||
|
||
| if 'package_url' in metadata_fields: | ||
| package_data.update(PackageURL.from_string(metadata_fields['package_url']).to_dict()) | ||
| yield models.PackageData.from_data(package_data, package_only=True) | ||
|
|
||
|
|
||
| @classmethod | ||
| def assign_package_to_resources(cls, package, resource, codebase, package_adder): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| METADATA = { | ||
| "licenses": [ | ||
| "BSD-3-Clause", | ||
| ], | ||
| "maintainers": [ | ||
| "oss_foundation", | ||
| ], | ||
| "name": "androidx.compose.animation:animation", | ||
| "upstream_address": "https://developer.android.com/jetpack/androidx/releases/compose-animation#0.0.1", | ||
| "version": "0.0.1", | ||
| "package_url" : "pkg:maven/androidx.compose.animation/[email protected]" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you maybe link to some examples of this type of manifests with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, I cannot link you one of our internal files. However my example file is very close to an actual file (the version number is wrong but that's all).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No worries on that obviously, but can you find some other real examples with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I searched on GitHub but did not find any other files that use that field but also I did not find many examples of bzl files at all. So perhaps it is not very common (yet?). |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.