aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-08-30 08:55:25 +0200
committerGitHub <noreply@github.com>2023-08-30 06:55:25 +0000
commit5315153059529f03b06c8f25487ffcc21ae3163f (patch)
treeb5f90daf2f1916f37656369865706d95872a7ae7 /build
parent815d267c8031daa19b82b291a6393a54715567c0 (diff)
downloadgitea-5315153059529f03b06c8f25487ffcc21ae3163f.tar.gz
gitea-5315153059529f03b06c8f25487ffcc21ae3163f.zip
Use `Set[Type]` instead of `map[Type]bool/struct{}`. (#26804)
Diffstat (limited to 'build')
-rw-r--r--build/backport-locales.go7
-rw-r--r--build/generate-go-licenses.go14
2 files changed, 9 insertions, 12 deletions
diff --git a/build/backport-locales.go b/build/backport-locales.go
index 0346215348..d112dd72bd 100644
--- a/build/backport-locales.go
+++ b/build/backport-locales.go
@@ -12,6 +12,7 @@ import (
"path/filepath"
"strings"
+ "code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/setting"
)
@@ -58,7 +59,7 @@ func main() {
// use old en-US as the base, and copy the new translations to the old locales
enUsOld := inisOld["options/locale/locale_en-US.ini"]
- brokenWarned := map[string]bool{}
+ brokenWarned := make(container.Set[string])
for path, iniOld := range inisOld {
if iniOld == enUsOld {
continue
@@ -77,7 +78,7 @@ func main() {
broken := oldStr != "" && strings.Count(oldStr, "%") != strings.Count(newStr, "%")
broken = broken || strings.Contains(oldStr, "\n") || strings.Contains(oldStr, "\n")
if broken {
- brokenWarned[secOld.Name()+"."+keyEnUs.Name()] = true
+ brokenWarned.Add(secOld.Name() + "." + keyEnUs.Name())
fmt.Println("----")
fmt.Printf("WARNING: skip broken locale: %s , [%s] %s\n", path, secEnUS.Name(), keyEnUs.Name())
fmt.Printf("\told: %s\n", strings.ReplaceAll(oldStr, "\n", "\\n"))
@@ -103,7 +104,7 @@ func main() {
broken = broken || strings.HasPrefix(str, "`\"")
broken = broken || strings.Count(str, `"`)%2 == 1
broken = broken || strings.Count(str, "`")%2 == 1
- if broken && !brokenWarned[sec.Name()+"."+key.Name()] {
+ if broken && !brokenWarned.Contains(sec.Name()+"."+key.Name()) {
fmt.Printf("WARNING: found broken locale: %s , [%s] %s\n", path, sec.Name(), key.Name())
fmt.Printf("\tstr: %s\n", strings.ReplaceAll(str, "\n", "\\n"))
fmt.Println("----")
diff --git a/build/generate-go-licenses.go b/build/generate-go-licenses.go
index c3b40c226f..84ba39025c 100644
--- a/build/generate-go-licenses.go
+++ b/build/generate-go-licenses.go
@@ -15,6 +15,8 @@ import (
"regexp"
"sort"
"strings"
+
+ "code.gitea.io/gitea/modules/container"
)
// regexp is based on go-license, excluding README and NOTICE
@@ -55,20 +57,14 @@ func main() {
// yml
//
// It could be removed once we have a better regex.
- excludedExt := map[string]bool{
- ".gitignore": true,
- ".go": true,
- ".mod": true,
- ".sum": true,
- ".toml": true,
- ".yml": true,
- }
+ excludedExt := container.SetOf(".gitignore", ".go", ".mod", ".sum", ".toml", ".yml")
+
var 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()) || excludedExt[filepath.Ext(entry.Name())] {
+ if entry.IsDir() || !licenseRe.MatchString(entry.Name()) || excludedExt.Contains(filepath.Ext(entry.Name())) {
return nil
}
paths = append(paths, path)