gitea/services/convert
yp05327 70b7df0e5e
Support repo license (#24872)
Close #278
Close #24076

## Solutions:
- Use
[google/licenseclassifier](https://github.com/google/licenseclassifier/)
Test result between
[google/licensecheck](https://github.com/google/licensecheck) and
[go-license-detector](https://github.com/go-enry/go-license-detector):
https://github.com/go-gitea/gitea/pull/24872#issuecomment-1560361167
Test result between
[google/licensecheck](https://github.com/google/licensecheck) and
[google/licenseclassifier](https://github.com/google/licenseclassifier/):
https://github.com/go-gitea/gitea/pull/24872#issuecomment-1576092178
- Generate License Convert Name List to avoid import license templates
with same contents
Gitea automatically get latest license data from[
spdx/license-list-data](https://github.com/spdx/license-list-data).
But unfortunately, some license templates have same contents. #20915
[click here to see the
list](https://github.com/go-gitea/gitea/pull/24872#issuecomment-1584141684)
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)
- Save License info into a new table `repo_license`
Can easily support searching repo by license in the future.

## Screen shot
Single License:

![image](https://github.com/go-gitea/gitea/assets/18380374/41260bd7-0b4c-4038-8592-508706cffa9f)

Multiple Licenses:

![image](https://github.com/go-gitea/gitea/assets/18380374/34ce2f73-7e18-446b-9b96-ecc4fb61bd70)

Triggers:
- [x] Push commit to default branch
- [x] Create repo
- [x] Mirror repo
- [x] When Default Branch is changed, licenses should be updated

Todo:
- [x] Save Licenses info in to DB when there's a change to license file
in the commit
- [x] DB Migration
- [x] A nominal test?
- [x] Select which library to
use(https://github.com/go-gitea/gitea/pull/24872#issuecomment-1560361167)
- [x] API Support
- [x] Add repo license table
- ~Select license in settings if there are several licenses(Not
recommended)~
- License board(later, not in this PR)

![image](https://github.com/go-gitea/gitea/assets/18380374/2c3c3bf8-bcc2-4c6d-8ce0-81d1a9733878)

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: 6543 <m.huber@kithara.com>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.com>
2024-10-01 15:25:08 -04:00
..
activity.go For API attachments, use API URL (#25639) 2023-07-10 09:31:19 +00:00
attachment.go Fix attachment download bug (#27486) 2023-10-10 15:33:56 +00:00
convert.go Fix /repos/{owner}/{repo}/pulls/{index}/files endpoint not populating previous_filename (#32017) 2024-09-12 01:29:27 +08:00
git_commit_test.go Adjust object format interface (#28469) 2023-12-17 11:56:08 +00:00
git_commit.go Move context from modules to services (#29440) 2024-02-27 08:12:22 +01:00
issue_comment.go Update misspell to 0.5.1 and add misspellings.csv (#30573) 2024-04-27 08:03:49 +00:00
issue_test.go Move convert package to services (#22264) 2022-12-29 10:57:15 +08:00
issue.go Performance improvements for pull request list API (#30490) 2024-05-31 12:10:11 +00:00
main_test.go make writing main test easier (#27270) 2023-09-28 01:38:53 +00:00
mirror.go Even more db.DefaultContext refactor (#27352) 2023-10-03 10:30:41 +00:00
notification.go Performance improvements for pull request list page (#29900) 2024-03-21 14:13:08 +01:00
package.go Clarify permission "HasAccess" behavior (#30585) 2024-04-20 03:15:04 +00:00
pull_review_test.go Fix possible NPE in ToPullReviewList (#29759) 2024-03-13 19:46:15 +00:00
pull_review.go Fix possible NPE in ToPullReviewList (#29759) 2024-03-13 19:46:15 +00:00
pull_test.go Fix Permission in API returned repository struct (#25388) 2023-06-22 13:08:08 +00:00
pull.go Fix null requested_reviewer from API (#31773) 2024-08-05 10:59:53 +00:00
release_test.go add Upload URL to release API (#26663) 2023-08-24 10:36:10 +00:00
release.go add Upload URL to release API (#26663) 2023-08-24 10:36:10 +00:00
repository.go Support repo license (#24872) 2024-10-01 15:25:08 -04:00
secret.go feat: implement organization secret creation API (#26566) 2023-08-22 11:20:34 +08:00
status.go refactor improve NoBetterThan (#26126) 2023-07-26 08:52:07 +00:00
user_test.go Add context cache as a request level cache (#22294) 2023-02-15 21:37:34 +08:00
user.go Make gitea webhooks openproject compatible (#28435) 2024-05-26 04:08:13 +00:00
utils_test.go Rewrite queue (#24505) 2023-05-08 19:49:59 +08:00
utils.go Support migration from AWS CodeCommit (#31981) 2024-09-11 07:49:42 +08:00
wiki.go Fix an actions schedule bug (#28942) 2024-01-31 14:55:12 +00:00