loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request '[I18N] make merge-locales & build/merge-forgejo-locales.go are noop' (#2864) from earl-warren/forgejo:wip-backward-locales into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2864
Reviewed-by: Otto <otto@codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>

Gusted 91b8874a f24478bf

+7 -124
+4
Makefile
··· 814 814 @echo "Running go generate..." 815 815 @CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES) 816 816 817 + .PHONY: merge-locales 818 + merge-locales: 819 + @echo "NOT NEEDED: THIS IS A NOOP AS OF Forgejo 7.0 BUT KEPT FOR BACKWARD COMPATIBILITY" 820 + 817 821 .PHONY: security-check 818 822 security-check: 819 823 go run $(GOVULNCHECK_PACKAGE) ./...
-27
build/crowdin-to-weblate.sh
··· 1 - #!/bin/bash 2 - # Copyright 2024 The Forgejo Authors 3 - # SPDX-License-Identifier: MIT 4 - 5 - D=/tmp/crowdin-to-weblate 6 - mkdir -p $D 7 - 8 - function checkout() { 9 - if test -d $D/gitea ; then 10 - git -C $D/gitea reset --hard 11 - return 12 - fi 13 - 14 - git clone --depth 1 https://github.com/go-gitea/gitea $D/gitea 15 - } 16 - 17 - function replace() { 18 - go run build/merge-forgejo-locales.go $D/gitea/options/locale 19 - cp -a $D/gitea/options/locale/* options/locale 20 - } 21 - 22 - function run() { 23 - checkout 24 - replace 25 - } 26 - 27 - "$@"
+3 -97
build/merge-forgejo-locales.go
··· 1 - // Copyright 2022 The Forgejo Authors c/o Codeberg e.V.. All rights reserved. 1 + // Copyright 2024 The Forgejo Authors c/o Codeberg e.V.. All rights reserved. 2 2 // Use of this source code is governed by a MIT-style 3 3 // license that can be found in the LICENSE file. 4 4 ··· 7 7 package main 8 8 9 9 import ( 10 - "bufio" 11 - "log" 12 - "os" 13 - "regexp" 14 - "strings" 15 - ) 16 - 17 - const ( 18 - trimPrefix = "gitea_" 19 - sourceFolder = "options/locales/" 10 + "fmt" 20 11 ) 21 12 22 - // returns list of locales, still containing the file extension! 23 - func generate_locale_list() []string { 24 - localeFiles, _ := os.ReadDir(sourceFolder) 25 - locales := []string{} 26 - for _, localeFile := range localeFiles { 27 - if !localeFile.IsDir() && strings.HasPrefix(localeFile.Name(), trimPrefix) { 28 - locales = append(locales, strings.TrimPrefix(localeFile.Name(), trimPrefix)) 29 - } 30 - } 31 - return locales 32 - } 33 - 34 - // replace all occurrences of Gitea with Forgejo 35 - func renameGiteaForgejo(filename string) []byte { 36 - file, err := os.Open(filename) 37 - if err != nil { 38 - panic(err) 39 - } 40 - 41 - replacements := []string{ 42 - "Gitea", "Forgejo", 43 - "https://docs.gitea.com/installation/install-from-binary", "https://forgejo.org/download/#installation-from-binary", 44 - "https://github.com/go-gitea/gitea/tree/master/docker", "https://forgejo.org/download/#container-image", 45 - "https://docs.gitea.com/installation/install-from-package", "https://forgejo.org/download", 46 - "https://code.gitea.io/gitea", "https://forgejo.org/download", 47 - "code.gitea.io/gitea", "Forgejo", 48 - `<a href="https://github.com/go-gitea/gitea/issues" target="_blank">GitHub</a>`, `<a href="https://codeberg.org/forgejo/forgejo/issues" target="_blank">Codeberg</a>`, 49 - "https://github.com/go-gitea/gitea", "https://codeberg.org/forgejo/forgejo", 50 - "https://blog.gitea.io", "https://forgejo.org/news", 51 - "https://docs.gitea.com/usage/protected-tags", "https://forgejo.org/docs/latest/user/protection/#protected-tags", 52 - "https://docs.gitea.com/usage/webhooks", "https://forgejo.org/docs/latest/user/webhooks/", 53 - } 54 - replacer := strings.NewReplacer(replacements...) 55 - replaced := make(map[string]bool, len(replacements)/2) 56 - count_replaced := func(original string) { 57 - for i := 0; i < len(replacements); i += 2 { 58 - if strings.Contains(original, replacements[i]) { 59 - replaced[replacements[i]] = true 60 - } 61 - } 62 - } 63 - 64 - out := make([]byte, 0, 1024) 65 - scanner := bufio.NewScanner(file) 66 - scanner.Split(bufio.ScanLines) 67 - for scanner.Scan() { 68 - line := scanner.Text() 69 - 70 - if strings.HasPrefix(line, "license_desc=") { 71 - line = strings.Replace(line, "GitHub", "Forgejo", 1) 72 - } 73 - 74 - if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") { 75 - out = append(out, []byte(line+"\n")...) 76 - } else if strings.HasPrefix(line, "settings.web_hook_name_gitea") { 77 - out = append(out, []byte(line+"\n")...) 78 - out = append(out, []byte("settings.web_hook_name_forgejo = Forgejo\n")...) 79 - } else if strings.HasPrefix(line, "migrate.gitea.description") { 80 - re := regexp.MustCompile(`(.*Gitea)`) 81 - out = append(out, []byte(re.ReplaceAllString(line, "${1}/Forgejo")+"\n")...) 82 - } else { 83 - count_replaced(line) 84 - out = append(out, []byte(replacer.Replace(line)+"\n")...) 85 - } 86 - } 87 - file.Close() 88 - if strings.HasSuffix(filename, "gitea_en-US.ini") { 89 - for i := 0; i < len(replacements); i += 2 { 90 - if replaced[replacements[i]] == false { 91 - log.Fatalf("%s was never used to replace something in %s, it is obsolete and must be updated", replacements[i], filename) 92 - } 93 - } 94 - } 95 - return out 96 - } 97 - 98 13 func main() { 99 - d := os.Args[1] 100 - files, err := os.ReadDir(d) 101 - if err != nil { 102 - log.Fatal(err) 103 - } 104 - 105 - for _, f := range files { 106 - p := d + "/" + f.Name() 107 - os.WriteFile(p, renameGiteaForgejo(p), 0o644) 108 - } 14 + fmt.Println("NOT NEEDED: THIS IS A NOOP AS OF Forgejo 7.0 BUT KEPT FOR BACKWARD COMPATIBILITY") 109 15 }