feat(licenses): support REUSE specification in licenses (#38720)

extends the current license detection to support two modes:
- legacy which is using classification and was expanded to handle more
paths (extensions, different spelling or GNU copying file)
- REUSE which avoids classification by relying on the spec dictating
that license must be named as SPDX-ID.extension. Newly created
repositories will default to REUSE based paths

Use of styles at the same time is not allowed by design.

Extends the UI to show all the detected licenses and paths to them,
deduplicating them per SPDX-ID in database as is in github

closes: https://github.com/go-gitea/gitea/issues/28672


---------

Assisted-By: omp:glm5.2
Assisted-By: omp:mimo-v2.5-pro
Assisted-By: omp:mimimax-m3
Assisted-By: omp:kimi-k3
Assisted-By: omp:deepseek-v4-flash
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
TheFox0x7
2026-08-03 07:34:53 +00:00
committed by GitHub
co-authored by wxiaoguang
parent 09f7c71e3d
commit e23fe79e5e
10 changed files with 479 additions and 70 deletions
+4 -3
View File
@@ -51,9 +51,10 @@
</a>
{{end}}
{{if .DetectedRepoLicenses}}
<a class="flex-text-block muted" href="{{.RepoLink}}/src/{{.Repository.DefaultBranch}}/{{PathEscapeSegments .LicenseFileName}}" title="{{StringUtils.Join .DetectedRepoLicenses ", "}}">
{{svg "octicon-law"}} {{if eq (len .DetectedRepoLicenses) 1}}{{index .DetectedRepoLicenses 0}}{{else}}{{ctx.Locale.Tr "repo.multiple_licenses"}}{{end}}
{{range $licenseGroup := .LicenseGroups}}
{{$licenseDisplayName := StringUtils.Join $licenseGroup.LicenseNames ", "}}
<a class="flex-text-block muted" title="{{$licenseDisplayName}}" href="{{$.RepoLink}}/src/{{$.Repository.DefaultBranch}}/{{PathEscapeSegments $licenseGroup.LicensePath}}">
{{svg "octicon-law"}} {{$licenseDisplayName}}
</a>
{{end}}