forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
* upstream/main: Make the vscode clone link respect transport protocol (go-gitea#20557) Fix typo of issue template name (go-gitea#21117) [skip ci] Updated translations via Crowdin Fix pagination limit parameter problem (go-gitea#21109) Rewrite go license generator in go (go-gitea#21078) Allow uppercase ASCII alphabet in PyPI package names (go-gitea#21095) Fix various typos (go-gitea#21103) Update docs issue-pull-request-templates.zh-cn.md (go-gitea#21030) Upgrade the document about how to collect logs for systemd and docker (go-gitea#21101)
- Loading branch information
Showing
27 changed files
with
795 additions
and
296 deletions.
There are no files selected for viewing
This file contains 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 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,74 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build ignore | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"io/fs" | ||
"os" | ||
"path/filepath" | ||
"regexp" | ||
"sort" | ||
"strings" | ||
) | ||
|
||
// regexp is based on go-license, excluding README and NOTICE | ||
// https://github.com/google/go-licenses/blob/master/licenses/find.go | ||
var licenseRe = regexp.MustCompile(`^(?i)((UN)?LICEN(S|C)E|COPYING).*$`) | ||
|
||
type LicenseEntry struct { | ||
Name string `json:"name"` | ||
Path string `json:"path"` | ||
LicenseText string `json:"licenseText"` | ||
} | ||
|
||
func main() { | ||
base, out := os.Args[1], os.Args[2] | ||
|
||
paths := []string{} | ||
err := filepath.WalkDir(base, func(path string, entry fs.DirEntry, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
if entry.IsDir() || !licenseRe.MatchString(entry.Name()) { | ||
return nil | ||
} | ||
paths = append(paths, path) | ||
return nil | ||
}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
sort.Strings(paths) | ||
|
||
entries := []LicenseEntry{} | ||
for _, path := range paths { | ||
licenseText, err := os.ReadFile(path) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
path := strings.Replace(path, base+string(os.PathSeparator), "", 1) | ||
|
||
entries = append(entries, LicenseEntry{ | ||
Name: filepath.Dir(path), | ||
Path: path, | ||
LicenseText: string(licenseText), | ||
}) | ||
} | ||
|
||
jsonBytes, err := json.MarshalIndent(entries, "", " ") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
err = os.WriteFile(out, jsonBytes, 0o644) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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 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
Oops, something went wrong.