- 
 
 - 
  Notifications
 
You must be signed in to change notification settings  - Fork 6.2k
 
Support repo license #24872
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
Support repo license #24872
Conversation
Did you compare https://github.com/go-enry/go-license-detector vs. https://github.com/google/licensecheck?
The last commit on google/licensecheck is from one Year ago, so it looks like it is not developed anymore. I would suggest using go-enry/go-license-detector.
The last commit on google/licensecheck is from one Year ago, so it looks like it is not developed anymore. I would suggest using go-enry/go-license-detector.
They should be compared by more than just that, ideally by feeding them a corpus of oddly licensed repos. One thing i'd be interested in if any of the two can detect license field in package.json for example.
Select license in settings if there are several licenses?
I wouldn't. License detection should be fully automatic and not overrideable, so that the git repo remains portable and is not tied to gitea-specific license override that can not be migrated.
Save Licenses info in to DB when there's a change to license file in the commit?
Some form of cache would be nice to not calculate license every render, but instead only on push to the branch.
License board?
Seems nice but I'd say something for later, and only if we can outsource the license metadata.
Thanks for this PR <3
Could you add at least a nominal test, as while upstream is tested we should ensure that our use of the library is acceptable.
I do think the storage of information in the database is a good idea as that's what we do with language stats.
As for which library we use, there are pros/cons for both. The google one is used by pkg.go.dev, and for enry we already use their library for language stats. Although I suspect that they both are somewhat close to getting what the actual license issue. so I think unless there is some significant performance impact or one library is wildly inaccurate either is fine.
I tried the CLI tool of go-license-detector.
There are two problems:
- 
Performance problem
go-license-detectorcan automatically search license files which seems good,
but if an unrelated big size file's name starts withlicense, it will takes lots of time to get the result.
For example, in this folder:
image
Run./license-detector ./1is very fast, but./license-detector ./will take a lot of time.
image
image
(It is too slow, so I canceled the process)And, for
google/licensecheck, it only takes about 10s to finish the detection.
image
So it seems thatgoogle/licensecheckhas higher performance.
(削除) (Is it caused by different IO process? The test of license-detector used it's own IO process, the test of licensecheck used charset? Not sure about this now.) (削除ここまで)
Test code:
image
Test Result:
image
(Stopped atlicensedb.InvestigateLicenseTextfor long time) - 
Detect multi licenses.
It seems thatgo-license-detectorcan not detect multi licenses in one file.
In https://github.com/yp05327/test, there are two licenses inLICENSE
In https://github.com/yp05327/test2, there is only one license inLICENSE
but the result is same:
image
image
google/licensecheck can detect all of them.
image 
70b7df0
 into
 
 
 go-gitea:main
 
 * giteaofficial/main: Fix javascript error when an anonymous user visiting migration page (go-gitea#32144) Make oauth2 code clear. Move oauth2 provider code to their own packages/files (go-gitea#32148) Support repo license (go-gitea#24872) Fix the logic of finding the latest pull review commit ID (go-gitea#32139) Ensure `GetCSRF` doesn't return an empty token (go-gitea#32130) Bump minio-go to latest version (go-gitea#32156)
Uh oh!
There was an error while loading. Please reload this page.
Close #278
Close #24076
Solutions:
Test result between google/licensecheck and go-license-detector:
Support repo license #24872 (comment)
Test result between google/licensecheck and google/licenseclassifier:
Support repo license #24872 (comment)
Gitea automatically get latest license data from spdx/license-list-data.
But unfortunately, some license templates have same contents. Duplicate license options with identical contents #20915 click here to see the list
So we will generate a list of these license templates with same contents and create a new file to save the result when using
make generate-license. (Need to decide the save path)repo_licenseCan easily support searching repo by license in the future.
Screen shot
Single License:
image
Multiple Licenses:
image
Triggers:
Todo:
(削除) Select license in settings if there are several licenses(Not recommended) (削除ここまで)image