Skip to content

Commit dc2ddab

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Remove follow from commits by file (go-gitea#20765) [skip ci] Updated translations via Crowdin Fix `make watch` for generated files (go-gitea#20794) Add missing translation for queue flush workers (go-gitea#20791) Update zh-cn translation for Installation from source (go-gitea#20772) Improve comment header for Mobile (go-gitea#20781) Add myself to MAINTAINERS (go-gitea#20786) [skip ci] Updated licenses and gitignores Preserve unix socket file (go-gitea#20499) Switch Unicode Escaping to a VSCode-like system (go-gitea#19990) Fix git.Init for doctor sub-command (go-gitea#20782) Remove the translation key website by PR go-gitea#20777 (go-gitea#20779) Move the official website link at the footer of gitea (go-gitea#20777) Remove useless JS operation for relative time tooltips (go-gitea#20756) Remove debug output when coverage fails (go-gitea#20733) Slightly reduce exclamation icon size (go-gitea#20753)
2 parents 27f7758 + 58a4407 commit dc2ddab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2507
-443
lines changed

.air.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ bin = "gitea"
77
include_ext = ["go", "tmpl"]
88
exclude_dir = ["modules/git/tests", "services/gitdiff/testdata", "modules/avatar/testdata"]
99
include_dir = ["cmd", "models", "modules", "options", "routers", "services", "templates"]
10-
exclude_regex = ["_test.go$"]
10+
exclude_regex = ["_test.go$", "_gen.go$"]

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ Leon Hofmeister <dev.lh@web.de> (@delvh)
4747
Gusted <williamzijl7@hotmail.com) (@Gusted)
4848
silentcode <silentcode@senga.org> (@silentcodeg)
4949
Wim <wim@42.be> (@42wim)
50+
xinyu <xinyu@nerv.org.cn> (@penlinux)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ test\#%:
364364
coverage:
365365
grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out
366366
grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' integration.coverage.out > integration.coverage-bodged.out
367-
$(GO) run build/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all || (echo "gocovmerge failed"; echo "integration.coverage.out"; cat integration.coverage.out; echo "coverage.out"; cat coverage.out; exit 1)
367+
$(GO) run build/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all
368368

369369
.PHONY: unit-test-coverage
370370
unit-test-coverage:

cmd/doctor.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"code.gitea.io/gitea/models/db"
1515
"code.gitea.io/gitea/models/migrations"
1616
"code.gitea.io/gitea/modules/doctor"
17-
"code.gitea.io/gitea/modules/git"
1817
"code.gitea.io/gitea/modules/log"
1918
"code.gitea.io/gitea/modules/setting"
2019

@@ -128,11 +127,6 @@ func runDoctor(ctx *cli.Context) error {
128127
stdCtx, cancel := installSignals()
129128
defer cancel()
130129

131-
// some doctor sub-commands need to use git command
132-
if err := git.InitFull(stdCtx); err != nil {
133-
return err
134-
}
135-
136130
// Silence the default loggers
137131
log.DelNamedLogger("console")
138132
log.DelNamedLogger(log.DEFAULT)

docs/content/doc/installation/from-source.zh-cn.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,35 @@ menu:
1515

1616
# 从源代码安装
1717

18-
首先你需要安装Golang,关于Golang的安装,参见官方文档 [install instructions](https://golang.org/doc/install)
18+
首先你需要安装Golang,关于Golang的安装,参见[官方文档](https://golang.google.cn/doc/install)
19+
20+
其次你需要[安装Node.js](https://nodejs.org/zh-cn/download/),Node.js 和 npm 将用于构建 Gitea 前端。
21+
22+
**目录**
23+
24+
{{< toc >}}
1925

2026
## 下载
2127

22-
你需要获取Gitea的源码,最方便的方式是使用 go 命令。执行以下命令:
28+
你需要获取Gitea的源码,最方便的方式是使用 `git` 命令。执行以下命令:
2329

2430
```
25-
go get -d -u code.gitea.io/gitea
26-
cd $GOPATH/src/code.gitea.io/gitea
31+
git clone https://github.com/go-gitea/gitea
32+
cd gitea
2733
```
2834

29-
然后你可以选择编译和安装的版本,当前你有多个选择。如果你想编译 `master` 版本,你可以直接跳到 [编译](#编译) 部分,这是我们的开发分支,虽然也很稳定但不建议您在正式产品中使用。
35+
然后你可以选择编译和安装的版本,当前你有多个选择。如果你想编译 `main` 版本,你可以直接跳到 [编译](#编译) 部分,这是我们的开发分支,虽然也很稳定但不建议您在正式产品中使用。
3036

3137
如果你想编译最新稳定分支,你可以执行以下命令签出源码:
3238

33-
```
39+
```bash
3440
git branch -a
3541
git checkout v{{< version >}}
3642
```
3743

3844
最后,你也可以直接使用标签版本如 `v{{< version >}}`。你可以执行以下命令列出可用的版本并选择某个版本签出:
3945

40-
```
46+
```bash
4147
git tag -l
4248
git checkout v{{< version >}}
4349
```
@@ -46,11 +52,11 @@ git checkout v{{< version >}}
4652

4753
要从源代码进行编译,以下依赖程序必须事先安装好:
4854

49-
- `go` {{< min-go-version >}} 或以上版本, 详见 [here](https://golang.org/dl/)
50-
- `node` {{< min-node-version >}} 或以上版本,并且安装 `npm`, 详见 [here](https://nodejs.org/en/download/)
51-
- `make`, 详见 <a href='{{< relref "make.zh-cn.md" >}}'>这里</a>
55+
- `go` {{< min-go-version >}} 或以上版本, 详见[这里](https://golang.google.cn/doc/install)
56+
- `node` {{< min-node-version >}} 或以上版本,并且安装 `npm`, 详见[这里](https://nodejs.org/zh-cn/download/)
57+
- `make`, 详见[这里]({{< relref "make.zh-cn.md" >}})</a>
5258

53-
各种可用的 [make 任务](https://github.com/go-gitea/gitea/blob/master/Makefile)
59+
各种可用的 [make 任务](https://github.com/go-gitea/gitea/blob/main/Makefile)
5460
可以用来使编译过程更方便。
5561

5662
按照您的编译需求,以下 tags 可以使用:
@@ -76,10 +82,26 @@ TAGS="bindata sqlite sqlite_unlock_notify" make build
7682

7783
在执行了以上步骤之后,你将会获得 `gitea` 的二进制文件,在你复制到部署的机器之前可以先测试一下。在命令行执行完后,你可以 `Ctrl + C` 关掉程序。
7884

79-
```
85+
```bash
8086
./gitea web
8187
```
8288

89+
## 交叉编译
90+
91+
Go 编译器支持交叉编译到不同的目标架构。有关 Go 支持的目标架构列表,请参见 [Optional environment variables](https://go.dev/doc/install/source#environment)
92+
93+
交叉构建适用于 Linux ARM64 的 Gitea:
94+
95+
```bash
96+
GOOS=linux GOARCH=arm64 make build
97+
```
98+
99+
交叉构建适用于 Linux ARM64 的 Gitea,并且带上 Gitea 发行版采用的编译选项:
100+
101+
```bash
102+
CC=aarch64-unknown-linux-gnu-gcc GOOS=linux GOARCH=arm64 TAGS="bindata sqlite sqlite_unlock_notify" make build
103+
```
104+
83105
## 需要帮助?
84106

85107
如果从本页中没有找到你需要的内容,请访问 [帮助页面]({{< relref "seek-help.zh-cn.md" >}})

integrations/repo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func testViewRepo(t *testing.T) {
6464
}
6565
})
6666

67-
f.commitTime, _ = s.Find("span.time-since").Attr("title")
67+
f.commitTime, _ = s.Find("span.time-since").Attr("data-content")
6868
items = append(items, f)
6969
})
7070

modules/charset/ambiguous.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// This file is generated by modules/charset/ambiguous/generate.go DO NOT EDIT
2+
// Copyright 2022 The Gitea Authors. All rights reserved.
3+
// Use of this source code is governed by a MIT-style
4+
// license that can be found in the LICENSE file.
5+
6+
package charset
7+
8+
import (
9+
"sort"
10+
"strings"
11+
"unicode"
12+
13+
"code.gitea.io/gitea/modules/translation"
14+
)
15+
16+
// AmbiguousTablesForLocale provides the table of ambiguous characters for this locale.
17+
func AmbiguousTablesForLocale(locale translation.Locale) []*AmbiguousTable {
18+
key := locale.Language()
19+
var table *AmbiguousTable
20+
var ok bool
21+
for len(key) > 0 {
22+
if table, ok = AmbiguousCharacters[key]; ok {
23+
break
24+
}
25+
idx := strings.LastIndexAny(key, "-_")
26+
if idx < 0 {
27+
key = ""
28+
} else {
29+
key = key[:idx]
30+
}
31+
}
32+
if table == nil {
33+
table = AmbiguousCharacters["_default"]
34+
}
35+
36+
return []*AmbiguousTable{
37+
table,
38+
AmbiguousCharacters["_common"],
39+
}
40+
}
41+
42+
func isAmbiguous(r rune, confusableTo *rune, tables ...*AmbiguousTable) bool {
43+
for _, table := range tables {
44+
if !unicode.Is(table.RangeTable, r) {
45+
continue
46+
}
47+
i := sort.Search(len(table.Confusable), func(i int) bool {
48+
return table.Confusable[i] >= r
49+
})
50+
(*confusableTo) = table.With[i]
51+
return true
52+
}
53+
return false
54+
}

modules/charset/ambiguous/ambiguous.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

modules/charset/ambiguous/generate.go

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"bytes"
9+
"flag"
10+
"fmt"
11+
"go/format"
12+
"os"
13+
"sort"
14+
"text/template"
15+
"unicode"
16+
17+
"code.gitea.io/gitea/modules/json"
18+
19+
"golang.org/x/text/unicode/rangetable"
20+
)
21+
22+
// ambiguous.json provides a one to one mapping of ambiguous characters to other characters
23+
// See https://github.com/hediet/vscode-unicode-data/blob/main/out/ambiguous.json
24+
25+
type AmbiguousTable struct {
26+
Confusable []rune
27+
With []rune
28+
Locale string
29+
RangeTable *unicode.RangeTable
30+
}
31+
32+
type RunePair struct {
33+
Confusable rune
34+
With rune
35+
}
36+
37+
var verbose bool
38+
39+
func main() {
40+
flag.Usage = func() {
41+
fmt.Fprintf(os.Stderr, `%s: Generate AmbiguousCharacter
42+
43+
Usage: %[1]s [-v] [-o output.go] ambiguous.json
44+
`, os.Args[0])
45+
flag.PrintDefaults()
46+
}
47+
48+
output := ""
49+
flag.BoolVar(&verbose, "v", false, "verbose output")
50+
flag.StringVar(&output, "o", "ambiguous_gen.go", "file to output to")
51+
flag.Parse()
52+
input := flag.Arg(0)
53+
if input == "" {
54+
input = "ambiguous.json"
55+
}
56+
57+
bs, err := os.ReadFile(input)
58+
if err != nil {
59+
fatalf("Unable to read: %s Err: %v", input, err)
60+
}
61+
62+
var unwrapped string
63+
if err := json.Unmarshal(bs, &unwrapped); err != nil {
64+
fatalf("Unable to unwrap content in: %s Err: %v", input, err)
65+
}
66+
67+
fromJSON := map[string][]uint32{}
68+
if err := json.Unmarshal([]byte(unwrapped), &fromJSON); err != nil {
69+
fatalf("Unable to unmarshal content in: %s Err: %v", input, err)
70+
}
71+
72+
tables := make([]*AmbiguousTable, 0, len(fromJSON))
73+
for locale, chars := range fromJSON {
74+
table := &AmbiguousTable{Locale: locale}
75+
table.Confusable = make([]rune, 0, len(chars)/2)
76+
table.With = make([]rune, 0, len(chars)/2)
77+
pairs := make([]RunePair, len(chars)/2)
78+
for i := 0; i < len(chars); i += 2 {
79+
pairs[i/2].Confusable, pairs[i/2].With = rune(chars[i]), rune(chars[i+1])
80+
}
81+
sort.Slice(pairs, func(i, j int) bool {
82+
return pairs[i].Confusable < pairs[j].Confusable
83+
})
84+
for _, pair := range pairs {
85+
table.Confusable = append(table.Confusable, pair.Confusable)
86+
table.With = append(table.With, pair.With)
87+
}
88+
table.RangeTable = rangetable.New(table.Confusable...)
89+
tables = append(tables, table)
90+
}
91+
sort.Slice(tables, func(i, j int) bool {
92+
return tables[i].Locale < tables[j].Locale
93+
})
94+
data := map[string]interface{}{
95+
"Tables": tables,
96+
}
97+
98+
if err := runTemplate(generatorTemplate, output, &data); err != nil {
99+
fatalf("Unable to run template: %v", err)
100+
}
101+
}
102+
103+
func runTemplate(t *template.Template, filename string, data interface{}) error {
104+
buf := bytes.NewBuffer(nil)
105+
if err := t.Execute(buf, data); err != nil {
106+
return fmt.Errorf("unable to execute template: %w", err)
107+
}
108+
bs, err := format.Source(buf.Bytes())
109+
if err != nil {
110+
verbosef("Bad source:\n%s", buf.String())
111+
return fmt.Errorf("unable to format source: %w", err)
112+
}
113+
file, err := os.Create(filename)
114+
if err != nil {
115+
return fmt.Errorf("failed to create file %s because %w", filename, err)
116+
}
117+
defer file.Close()
118+
_, err = file.Write(bs)
119+
if err != nil {
120+
return fmt.Errorf("unable to write generated source: %w", err)
121+
}
122+
return nil
123+
}
124+
125+
var generatorTemplate = template.Must(template.New("ambiguousTemplate").Parse(`// This file is generated by modules/charset/ambiguous/generate.go DO NOT EDIT
126+
// Copyright 2022 The Gitea Authors. All rights reserved.
127+
// Use of this source code is governed by a MIT-style
128+
// license that can be found in the LICENSE file.
129+
130+
package charset
131+
132+
import "unicode"
133+
134+
// This file is generated from https://github.com/hediet/vscode-unicode-data/blob/main/out/ambiguous.json
135+
136+
// AmbiguousTable matches a confusable rune with its partner for the Locale
137+
type AmbiguousTable struct {
138+
Confusable []rune
139+
With []rune
140+
Locale string
141+
RangeTable *unicode.RangeTable
142+
}
143+
144+
// AmbiguousCharacters provides a map by locale name to the confusable characters in that locale
145+
var AmbiguousCharacters = map[string]*AmbiguousTable{
146+
{{range .Tables}}{{printf "%q:" .Locale}} {
147+
Confusable: []rune{ {{range .Confusable}}{{.}},{{end}} },
148+
With: []rune{ {{range .With}}{{.}},{{end}} },
149+
Locale: {{printf "%q" .Locale}},
150+
RangeTable: &unicode.RangeTable{
151+
R16: []unicode.Range16{
152+
{{range .RangeTable.R16 }} {Lo:{{.Lo}}, Hi:{{.Hi}}, Stride: {{.Stride}}},
153+
{{end}} },
154+
R32: []unicode.Range32{
155+
{{range .RangeTable.R32}} {Lo:{{.Lo}}, Hi:{{.Hi}}, Stride: {{.Stride}}},
156+
{{end}} },
157+
LatinOffset: {{.RangeTable.LatinOffset}},
158+
},
159+
},
160+
{{end}}
161+
}
162+
163+
`))
164+
165+
func logf(format string, args ...interface{}) {
166+
fmt.Fprintf(os.Stderr, format+"\n", args...)
167+
}
168+
169+
func verbosef(format string, args ...interface{}) {
170+
if verbose {
171+
logf(format, args...)
172+
}
173+
}
174+
175+
func fatalf(format string, args ...interface{}) {
176+
logf("fatal: "+format+"\n", args...)
177+
os.Exit(1)
178+
}

0 commit comments

Comments
 (0)