-
Notifications
You must be signed in to change notification settings - Fork 16
fix: remove fallback logic for Source Code Download URL #220
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
Open
meAndreea
wants to merge
2
commits into
sw360:main
Choose a base branch
from
meAndreea:fix/remove_fallback_of_source_download_url
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,10 +236,13 @@ def add_licenses(self, cx_comp: Component, data: Dict[str, Any]) -> None: | |
| data["mainLicenseIds"] = licenses | ||
|
|
||
| def prepare_release_data(self, cx_comp: Component) -> Dict[str, Any]: | ||
| """Create release data structure as expected by SW360 REST API | ||
| """Create the Release data structure as expected by SW360 REST API. | ||
|
|
||
| :param item: a single bill of materials item - a release | ||
| :type item: dictionary | ||
| If the Source Code Download URL is missing in the given Release, try to update the VCS/Repository URL | ||
| of the corresponding SW360 Component with the repository or website URL from the Release. | ||
|
|
||
| :param cx_comp: a single bill of materials item - a Release | ||
| :type cx_comp: Component | ||
| :return: the release | ||
| :rtype: release (dictionary) | ||
| """ | ||
|
|
@@ -251,6 +254,56 @@ def prepare_release_data(self, cx_comp: Component) -> Dict[str, Any]: | |
| src_url = str(CycloneDxSupport.get_ext_ref_source_url(cx_comp)) | ||
| if src_url: | ||
| data["sourceCodeDownloadurl"] = src_url | ||
| else: | ||
| print_red(" No Source Code Download URL found. Will try to update the VCS/Repository URL.") | ||
|
|
||
| # Try to update the VCS/Repository URL of the corresponding SW360 Component | ||
| # with the repository or website URL from the Release | ||
| component_id = CycloneDxSupport.get_property_value(cx_comp, CycloneDxSupport.CDX_PROP_COMPONENT_ID) | ||
| if not component_id: | ||
| print_red( | ||
| f" Unable to get the SW360 Component ID from the BOM item: {cx_comp.name}. " | ||
| "Will not update the VCS/Repository URL." | ||
| ) | ||
| elif not self.client: | ||
| print_red(" No SW360 client available. Will not update the VCS/Repository URL.") | ||
| else: | ||
| component = self.client.get_component(component_id) | ||
| if component is None: | ||
| print_red( | ||
| f" Unable to get the SW360 Component with ID: {component_id}. " | ||
| "Will not update the VCS/Repository URL." | ||
| ) | ||
| else: | ||
| website = CycloneDxSupport.get_ext_ref_website(cx_comp) | ||
| repo = CycloneDxSupport.get_ext_ref_repository(cx_comp) | ||
|
|
||
| current_vcs = component.get("vcs", "") | ||
| # Note: The VCS/Repository URL can only be updated after the rollout of Issue 1886 | ||
| # (https://code.siemens.com/sw360/sw360portal/-/issues/1886) - before that, | ||
| # the VCS/Repository URL is not available in the SW360 REST API and thus cannot be updated. | ||
| if repo: | ||
| print_yellow( | ||
| f" Not available until rollout of Issue 1886. " | ||
| f"Could update VCS/Repository URL from: {current_vcs if current_vcs else '<empty string>'} " | ||
| f"with repository: {repo}..." | ||
| ) | ||
| # try: | ||
| # updated_component = self.client.update_component({"vcs": str(repo)}, component_id) | ||
| # print_green(f" Successfully updated VCS/Repository URL to: {updated_component}") | ||
| # except SW360Error as e: | ||
| # print_red(f" Failed to update VCS/Repository URL: {e}") | ||
| elif website: | ||
| print_yellow( | ||
| f" Not available until rollout of Issue 1886. " | ||
|
Collaborator
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. Same here, please refer to eclipse-sw360/sw360-frontend#1357.
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. @gernot-h i removed this as well |
||
| f"Could update VCS/Repository URL from: {current_vcs if current_vcs else '<empty string>'} " | ||
| f"with website: {website}..." | ||
| ) | ||
| # try: | ||
| # updated_component = self.client.update_component({"vcs": str(website)}, component_id) | ||
| # print_green(f" Successfully updated VCS/Repository URL to: {updated_component}") | ||
| # except SW360Error as e: | ||
| # print_red(f" Failed to update VCS/Repository URL: {e}") | ||
|
|
||
| bin_url = str(CycloneDxSupport.get_ext_ref_binary_url(cx_comp)) | ||
| if bin_url: | ||
|
|
@@ -266,17 +319,6 @@ def prepare_release_data(self, cx_comp: Component) -> Dict[str, Any]: | |
| data["additionalData"] = {} | ||
| data["additionalData"]["createdWith"] = capycli.get_app_signature() | ||
|
|
||
| # use project site as fallback for source code download url | ||
| website = CycloneDxSupport.get_ext_ref_website(cx_comp) | ||
| repo = CycloneDxSupport.get_ext_ref_repository(cx_comp) | ||
| if not src_url: | ||
| if repo: | ||
| print(" Using repository for source code download URL...") | ||
| data["sourceCodeDownloadurl"] = str(repo) | ||
| elif website: | ||
| print(" Using website for source code download URL...") | ||
| data["sourceCodeDownloadurl"] = str(website) | ||
|
|
||
| language = CycloneDxSupport.get_property_value(cx_comp, CycloneDxSupport.CDX_PROP_LANGUAGE) | ||
| if language: | ||
| data["languages"] = [] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please refer to the public issue here: eclipse-sw360/sw360-frontend#1357.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gernot-h i removed this, not updating the vcs/repo of the corresponding Component for the sw360 Release that is preparing.