generated from aboutcode-org/skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 37
add on demand package data collection for golang, gitlab and bitbucket #596 #608
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
Merged
TG1999
merged 22 commits into
main
from
596_add_on-demand_package_data_collection_for_golang
Sep 9, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0882289
#596 - Added code for golang collector and updated the miner code for…
chinyeungli 1c1fbd7
#596 - Working in progress to handle bitbucket.org (It contains a lot…
chinyeungli b0f1a22
#596 - Added the following data collection for golang
chinyeungli 82cb1fb
Correct typo
chinyeungli 18f9413
#596 - Add on-demand package data collection for golang
chinyeungli 905195a
Update minecode/collectors/golang.py
chinyeungli 16e9fac
Merge branch 'main' into 596_add_on-demand_package_data_collection_fo…
chinyeungli cb18cb3
change from web scrapping to fetch from deps.dev #596
chinyeungli 1b5034e
Better error handling and remove test code #596
chinyeungli 7adce31
Correct ci_code_style #596
chinyeungli e3d973a
Merge branch 'main' into 596_add_on-demand_package_data_collection_fo…
chinyeungli fae4ff0
Upgrade to use packageurl-python 0.17.2 #596
chinyeungli 140de5b
Use "build_golang_download_url" to build the download url for go pack…
chinyeungli 674691d
Use branch of scancode.io #596
JonoYang dbfac90
update to use scancode-toolkit 32.4.0 #596
chinyeungli fdd3b51
Update packageurl-python to 0.17.3 #596
chinyeungli 1e204a6
Update packages dependencies
chinyeungli 4a8b4cf
Merge branch 'main' into 596_add_on-demand_package_data_collection_fo…
chinyeungli 711b97c
Add error handling for failing to fetch in fetchcode #596
chinyeungli 27d08de
Update code to use .get instead of using dict['item'] #596
chinyeungli e196df3
Revert code changes for build_bitbucket_packages()
chinyeungli 2497a53
Properly to use .get instead of using dict['item'] #596
chinyeungli 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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # | ||
| # Copyright (c) nexB Inc. and others. All rights reserved. | ||
| # purldb is a trademark of nexB Inc. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
| # See https://github.com/nexB/purldb for support or download. | ||
| # See https://aboutcode.org for more information about nexB OSS projects. | ||
| # | ||
|
|
||
| import logging | ||
|
|
||
| import requests | ||
|
|
||
|
|
||
| """ | ||
| Collect bitbucket packages from bitbucket registries. | ||
| """ | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
| handler = logging.StreamHandler() | ||
| logger.addHandler(handler) | ||
| logger.setLevel(logging.INFO) | ||
|
|
||
|
|
||
| def bitbucket_get_all_package_version_author(subset_path): | ||
| """ | ||
| Return a list of all version numbers along with author for the package. | ||
| """ | ||
| repo_tags = f"https://api.bitbucket.org/2.0/repositories/{subset_path}/refs/tags" | ||
| version_author_list = [] | ||
| try: | ||
| while repo_tags: | ||
| response = requests.get(repo_tags) | ||
| response.raise_for_status() | ||
| data = response.json() | ||
| if data["size"] > 0: | ||
| # Get all available versions | ||
| for item in data["values"]: | ||
| version = item.get("name") | ||
| target = item.get("target") or {} | ||
| author = target.get("author") or {} | ||
| if author.get("type") == "author": | ||
| user = author.get("user") or {} | ||
| author_display_name = user.get("display_name") | ||
| version_author_list.append((version, author_display_name)) | ||
| # Handle pagination | ||
| repo_tags = data.get("next", None) | ||
| return version_author_list | ||
| except requests.exceptions.HTTPError as err: | ||
| logger.error(f"HTTP error occurred: {err}") |
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
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
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # | ||
| # Copyright (c) nexB Inc. and others. All rights reserved. | ||
| # purldb is a trademark of nexB Inc. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
| # See https://github.com/nexB/purldb for support or download. | ||
| # See https://aboutcode.org for more information about nexB OSS projects. | ||
| # | ||
|
|
||
| import logging | ||
|
|
||
| import requests | ||
|
|
||
|
|
||
| """ | ||
| Collect gitlab packages from gitlab registries. | ||
| """ | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
| handler = logging.StreamHandler() | ||
| logger.addHandler(handler) | ||
| logger.setLevel(logging.INFO) | ||
|
|
||
|
|
||
| def gitlab_get_all_package_version_author(subset_path): | ||
| """ | ||
| Return a list of all version numbers along with author and author email | ||
| for the package. | ||
| """ | ||
| repo_tags = f"https://gitlab.com/api/v4/projects/{subset_path}/repository/tags" | ||
| try: | ||
| response = requests.get(repo_tags) | ||
| response.raise_for_status() | ||
| data = response.json() | ||
| version_author_list = [] | ||
| # Get all available versions | ||
| for item in data: | ||
|
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. IMO |
||
| version = item.get("name") | ||
| commit = item.get("commit") or {} | ||
| author = commit.get("author_name") or "" | ||
| author_email = commit.get("author_email") or "" | ||
| version_author_list.append((version, author, author_email)) | ||
| return version_author_list | ||
| except requests.exceptions.HTTPError as err: | ||
| logger.error(f"HTTP error occurred: {err}") | ||
Oops, something went wrong.
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.
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.
@chinyeungli could there be golang packages not from github?
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.
Yes. Only golang packages from github use this
map_fetchcode_supported_packagefunction.Others will use
map_golang_package()