diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-04-08 14:21:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-08 14:21:50 +0800 |
commit | 8f00979f732c976b75086f75ab7e776d2ee18771 (patch) | |
tree | 2f8490f87912e1f5bdd3fa55fa01ed9589e1add5 /build | |
parent | 7ee2c1336cddeb4c966d1d6f0dbe1e7680c1ee9a (diff) | |
download | gitea-8f00979f732c976b75086f75ab7e776d2ee18771.tar.gz gitea-8f00979f732c976b75086f75ab7e776d2ee18771.zip |
Drop "unrolled/render" package (#23965)
None of the features of `unrolled/render` package is used.
The Golang builtin "html/template" just works well. Then we can improve
our HTML render to resolve the "$.root.locale.Tr" problem as much as
possible.
Next step: we can have a template render pool (by Clone), then we can
inject global functions with dynamic context to every `Execute` calls.
Then we can use `{{Locale.Tr ....}}` directly in all templates , no need
to pass the `$.root.locale` again and again.
Diffstat (limited to 'build')
-rw-r--r-- | build/generate-go-licenses.go | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/build/generate-go-licenses.go b/build/generate-go-licenses.go index 7dd1ba38b4..bdac51e71c 100644 --- a/build/generate-go-licenses.go +++ b/build/generate-go-licenses.go @@ -7,9 +7,10 @@ package main import ( "encoding/json" + "fmt" "io/fs" "os" - goPath "path" + "path" "path/filepath" "regexp" "sort" @@ -27,9 +28,14 @@ type LicenseEntry struct { } func main() { + if len(os.Args) != 3 { + fmt.Println("usage: go run generate-go-licenses.go <base-dir> <out-json-file>") + os.Exit(1) + } + base, out := os.Args[1], os.Args[2] - paths := []string{} + var paths []string err := filepath.WalkDir(base, func(path string, entry fs.DirEntry, err error) error { if err != nil { return err @@ -46,28 +52,27 @@ func main() { sort.Strings(paths) - entries := []LicenseEntry{} - for _, path := range paths { - path := filepath.ToSlash(path) - - licenseText, err := os.ReadFile(path) + var entries []LicenseEntry + for _, filePath := range paths { + licenseText, err := os.ReadFile(filePath) if err != nil { panic(err) } - path = strings.Replace(path, base+"/", "", 1) - name := goPath.Dir(path) + pkgPath := filepath.ToSlash(filePath) + pkgPath = strings.TrimPrefix(pkgPath, base+"/") + pkgName := path.Dir(pkgPath) // There might be a bug somewhere in go-licenses that sometimes interprets the // root package as "." and sometimes as "code.gitea.io/gitea". Workaround by // removing both of them for the sake of stable output. - if name == "." || name == "code.gitea.io/gitea" { + if pkgName == "." || pkgName == "code.gitea.io/gitea" { continue } entries = append(entries, LicenseEntry{ - Name: name, - Path: path, + Name: pkgName, + Path: pkgPath, LicenseText: string(licenseText), }) } |