Skip to content
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

License rework #68

Merged
merged 80 commits into from
Oct 12, 2023
Merged

License rework #68

merged 80 commits into from
Oct 12, 2023

Conversation

rmfranken
Copy link
Member

@rmfranken rmfranken commented Sep 19, 2023

This PR implements license detection based on the GitHub/GitLab repository contents, as opposed to relying on the Git provider API to retrieve the license. In brief:

  • It adds a list_files() method to retrieve the list of file in the repo (names + download URLs)
  • It adds a _get_license() method which uses scancode to identify + classify license files
  • If allows multiple license for a single project in gimie's output.

…ncode-toolkit to match license. Not finished yet - as the returned scancode-toolkit output still has to be parsed to extract the spdx license, and I'm still getting a strange connection timeout most of the time (but not always!)
…arse it, match it against a spdx license and return that license.

still to do: Recursion - in case there are multiple licenses.
Refactoring - get rid of all the file writes and unnecessary prints, and build some functions which do one job only.
…nction documentation and reformatted with Black.
…ypes, remove trailing slashes from repo_URL so GitHub API can parse it.
… one big "get-license" function which calls all the other functions in order, using the singular input of repo_url which the user must supply.
…ut it inside the get_license function as a default variable. And black reformat.
… to github TREES instead of CONTENTS. The rest is the same - with a slightly unnecessary list-dictionary comprehension that hurts my head, which I will probably delete in the future.
…stead of a normal file now to prevent concurrent writes to the same filename.
…ecessary info, and then reusing the result in two different parts of the code
…ncode-toolkit to match license. Not finished yet - as the returned scancode-toolkit output still has to be parsed to extract the spdx license, and I'm still getting a strange connection timeout most of the time (but not always!)
…arse it, match it against a spdx license and return that license.

still to do: Recursion - in case there are multiple licenses.
Refactoring - get rid of all the file writes and unnecessary prints, and build some functions which do one job only.
…nction documentation and reformatted with Black.
…ypes, remove trailing slashes from repo_URL so GitHub API can parse it.
@rmfranken
Copy link
Member Author

Ok, @cmdoret I think I'm ready for your review, only 65 commits later. 🛠️ Hopefully it's the last one!

@cmdoret cmdoret self-requested a review October 11, 2023 07:18
Copy link
Member

@cmdoret cmdoret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! 😎

I had a few comments related to code organization, docstrings and type hints, but everything we need is here and it seems to work 👍

gimie/sources/common/license.py Outdated Show resolved Hide resolved
gimie/sources/common/license.py Outdated Show resolved Hide resolved
gimie/sources/common/license.py Outdated Show resolved Hide resolved
gimie/sources/common/license.py Outdated Show resolved Hide resolved
gimie/sources/github.py Outdated Show resolved Hide resolved
gimie/sources/gitlab.py Outdated Show resolved Hide resolved
…in API license (as this only works in GH). Instead, the license is found in the repository, and the scancode API is used to extract a license ID from that text. This license ID (with bad capitalization) is fed to the SPDX License dictionary to extract a SPDX license ID which is the final value output in a triple. This also works if multiple license files are present in a repo.
…n API license (as this only works in GH). Instead, the license is found in the repository, and the scancode API is used to extract a license ID from that text. This license ID (with bad capitalization) is fed to the SPDX License dictionary to extract a SPDX license ID which is the final value output in a triple. This also works if multiple license files are present in a repo.
…n API license (as this only works in GH). Instead, the license is found in the repository, and the scancode API is used to extract a license ID from that text. This license ID (with bad capitalization) is fed to the SPDX License dictionary to extract a SPDX license ID which is the final value output in a triple. This also works if multiple license files are present in a repo.
@rmfranken rmfranken merged commit a215d58 into main Oct 12, 2023
8 checks passed
@cmdoret cmdoret deleted the license_rework branch November 10, 2023 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants