Skip to content

Commit a5477b8

Browse files
committed
Merge branch 'main' into acss
* main: Remove publish docs CI workflow (go-gitea#24889) Fix double border and adjust width for user profile page (go-gitea#24870) Support changing git config through `app.ini`, use `diff.algorithm=histogram` by default (go-gitea#24860) Fix flakey test in logger test (go-gitea#24883) Run stylelint on .vue files (go-gitea#24865) Update `CONTRIBUTING.md` (go-gitea#24492) Do not call nil handler for a dummy queue (go-gitea#24880) Remove unnecessary usage prefix from doc titles (go-gitea#24869) Add API for Label templates (go-gitea#24602) Fix install page context, make the install page tests really test (go-gitea#24858) Add validations.required check to dropdown field (go-gitea#24849)
2 parents de96503 + 21add7e commit a5477b8

40 files changed

+904
-383
lines changed

.github/workflows/publish-docs.yml

-29
This file was deleted.

.stylelintrc.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ overrides:
1111
- files: ["**/chroma/*", "**/codemirror/*"]
1212
rules:
1313
block-no-empty: null
14+
- files: ["**/*.vue"]
15+
customSyntax: postcss-html
1416

1517
rules:
1618
alpha-value-notation: null
@@ -96,7 +98,7 @@ rules:
9698
property-no-vendor-prefix: null
9799
rule-empty-line-before: null
98100
rule-selector-property-disallowed-list: null
99-
scale-unlimited/declaration-strict-value: [[color, background-color, border-color, font-weight], {ignoreValues: /^(inherit|transparent|unset|initial|currentcolor|none)$/, ignoreFunctions: false}]
101+
scale-unlimited/declaration-strict-value: [[color, background-color, border-color, font-weight], {ignoreValues: /^(inherit|transparent|unset|initial|currentcolor|none)$/, ignoreFunctions: false, disableFix: true}]
100102
selector-attribute-name-disallowed-list: null
101103
selector-attribute-operator-allowed-list: null
102104
selector-attribute-operator-disallowed-list: null

CONTRIBUTING.md

+384-263
Large diffs are not rendered by default.

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,11 @@ lint-js-fix: node_modules
372372

373373
.PHONY: lint-css
374374
lint-css: node_modules
375-
npx stylelint --color --max-warnings=0 web_src/css
375+
npx stylelint --color --max-warnings=0 web_src/css web_src/js/components/*.vue
376376

377377
.PHONY: lint-css-fix
378378
lint-css-fix: node_modules
379-
npx stylelint --color --max-warnings=0 web_src/css --fix
379+
npx stylelint --color --max-warnings=0 web_src/css web_src/js/components/*.vue --fix
380380

381381
.PHONY: lint-swagger
382382
lint-swagger: node_modules

cmd/web.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,8 @@ func runWeb(ctx *cli.Context) error {
142142
return err
143143
}
144144
}
145-
installCtx, cancel := context.WithCancel(graceful.GetManager().HammerContext())
146-
c := install.Routes(installCtx)
145+
c := install.Routes()
147146
err := listen(c, false)
148-
cancel()
149147
if err != nil {
150148
log.Critical("Unable to open listener for installer. Is Gitea already running?")
151149
graceful.GetManager().DoGracefulShutdown()

custom/conf/app.example.ini

+22-26
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,28 @@ LEVEL = Info
682682
;; Disable the usage of using partial clones for git.
683683
;DISABLE_PARTIAL_CLONE = false
684684

685+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
686+
;; Git Operation timeout in seconds
687+
;[git.timeout]
688+
;DEFAULT = 360
689+
;MIGRATE = 600
690+
;MIRROR = 300
691+
;CLONE = 300
692+
;PULL = 300
693+
;GC = 60
694+
695+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
696+
;; Git Reflog timeout in days
697+
;[git.reflog]
698+
;ENABLED = true
699+
;EXPIRATION = 90
700+
701+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
702+
;; Git config options
703+
;; This section only does "set" config, a removed config key from this section won't be removed from git config automatically. The format is `some.configKey = value`.
704+
;[git.config]
705+
;diff.algorithm = histogram
706+
685707
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
686708
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
687709
[service]
@@ -2176,32 +2198,6 @@ LEVEL = Info
21762198
;Check at least this proportion of LFSMetaObjects per repo. (This may cause all stale LFSMetaObjects to be checked.)
21772199
;PROPORTION_TO_CHECK_PER_REPO = 0.6
21782200

2179-
2180-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2181-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2182-
;; Git Operation timeout in seconds
2183-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2184-
;[git.timeout]
2185-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2186-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2187-
;DEFAULT = 360
2188-
;MIGRATE = 600
2189-
;MIRROR = 300
2190-
;CLONE = 300
2191-
;PULL = 300
2192-
;GC = 60
2193-
2194-
2195-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2196-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2197-
;; Git Reflog timeout in days
2198-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2199-
;[git.reflog]
2200-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2201-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2202-
;ENABLED = true
2203-
;EXPIRATION = 90
2204-
22052201
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22062202
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22072203
;[mirror]

docs/content/doc/administration/backup-and-restore.zh-cn.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date: "2018-06-06T09:33:00+08:00"
3-
title: "使用:备份与恢复"
3+
title: "备份与恢复"
44
slug: "backup-and-restore"
55
weight: 11
66
toc: false

docs/content/doc/administration/config-cheat-sheet.en-us.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -1054,12 +1054,7 @@ Default templates for project boards:
10541054
- `DISABLE_CORE_PROTECT_NTFS`: **false** Set to true to forcibly set `core.protectNTFS` to false.
10551055
- `DISABLE_PARTIAL_CLONE`: **false** Disable the usage of using partial clones for git.
10561056

1057-
## Git - Reflog settings (`git.reflog`)
1058-
1059-
- `ENABLED`: **true** Set to true to enable Git to write changes to reflogs in each repo.
1060-
- `EXPIRATION`: **90** Reflog entry lifetime, in days. Entries are removed opportunistically by Git.
1061-
1062-
## Git - Timeout settings (`git.timeout`)
1057+
### Git - Timeout settings (`git.timeout`)
10631058

10641059
- `DEFAULT`: **360**: Git operations default timeout seconds.
10651060
- `MIGRATE`: **600**: Migrate external repositories timeout seconds.
@@ -1068,6 +1063,18 @@ Default templates for project boards:
10681063
- `PULL`: **300**: Git pull from internal repositories timeout seconds.
10691064
- `GC`: **60**: Git repository GC timeout seconds.
10701065

1066+
### Git - Reflog settings (`git.reflog`)
1067+
1068+
- `ENABLED`: **true** Set to true to enable Git to write changes to reflogs in each repo.
1069+
- `EXPIRATION`: **90** Reflog entry lifetime, in days. Entries are removed opportunistically by Git.
1070+
1071+
### Git - Config options (`git.config`)
1072+
1073+
The key/value pairs in this section will be used as git config.
1074+
This section only does "set" config, a removed config key from this section won't be removed from git config automatically. The format is `some.configKey = value`.
1075+
1076+
- `diff.algorithm`: **histogram**
1077+
10711078
## Metrics (`metrics`)
10721079

10731080
- `ENABLED`: **false**: Enables /metrics endpoint for prometheus.

docs/content/doc/administration/customizing-gitea.en-us.md

+16
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,22 @@ Place custom files in corresponding sub-folder under `custom/options`.
282282

283283
To add custom .gitignore, add a file with existing [.gitignore rules](https://git-scm.com/docs/gitignore) in it to `$GITEA_CUSTOM/options/gitignore`
284284

285+
## Customizing the git configuration
286+
287+
Starting with Gitea 1.20, you can customize the git configuration via the `git.config` section.
288+
289+
### Enabling signed git pushes
290+
291+
To enable signed git pushes, set these two options:
292+
293+
```ini
294+
[git.config]
295+
receive.advertisePushOptions = true
296+
receive.certNonceSeed = <randomstring>
297+
```
298+
299+
`certNonceSeed` should be set to a random string and be kept secret.
300+
285301
### Labels
286302

287303
Starting with Gitea 1.19, you can add a file that follows the [YAML label format](https://github.com/go-gitea/gitea/blob/main/options/label/Advanced.yaml) to `$GITEA_CUSTOM/options/label`:

docs/content/doc/administration/https-support.zh-cn.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date: "2023-04-09T11:00:00+02:00"
3-
title: "使用: HTTPS配置"
3+
title: "HTTPS配置"
44
slug: "https-setup"
55
weight: 12
66
toc: false

docs/content/doc/administration/reverse-proxies.zh-cn.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date: "2018-05-22T11:00:00+00:00"
3-
title: "使用:反向代理"
3+
title: "反向代理"
44
slug: "reverse-proxies"
55
weight: 16
66
toc: false

docs/content/doc/usage/issue-pull-request-templates.zh-cn.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date: "2022-09-07T16:00:00+08:00"
3-
title: "使用:从模板创建工单与合并请求"
3+
title: "工单与合并请求模板"
44
slug: "issue-pull-request-templates"
55
weight: 15
66
toc: true
@@ -10,7 +10,7 @@ aliases:
1010
menu:
1111
sidebar:
1212
parent: "usage"
13-
name: "从模板创建工单与合并请求"
13+
name: "工单与合并请求模板"
1414
weight: 15
1515
identifier: "issue-pull-request-templates"
1616
---

docs/content/doc/usage/profile-readme.en-us.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
date: "2023-03-02T21:00:00+05:00"
3-
title: "Usage: Gitea Profile READMEs"
3+
title: "Profile READMEs"
44
slug: "profile-readme"
55
weight: 12
66
toc: false
77
draft: false
88
menu:
99
sidebar:
1010
parent: "usage"
11-
name: "Gitea Profile READMEs"
11+
name: "Profile READMEs"
1212
weight: 12
1313
identifier: "profile-readme"
1414
---
1515

16-
# Gitea Profile READMEs
16+
# Profile READMEs
1717

1818
To display a markdown file in your Gitea profile page, simply make a repository named ".profile" and edit the README.md file inside. Gitea will automatically pull this file in and display it above your repositories.
1919

docs/content/doc/usage/pull-request.zh-cn.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date: "2018-06-01T19:00:00+02:00"
3-
title: "使用:Pull Request"
3+
title: "合并请求"
44
slug: "pull-request"
55
weight: 13
66
toc: false
@@ -15,9 +15,9 @@ menu:
1515
identifier: "pull-request"
1616
---
1717

18-
# Pull Request
18+
# 合并请求
1919

20-
## pull requests 使用“Work In Progress”标记
20+
## `合并请求`中使用“Work In Progress”标记
2121

2222
您可以通过在一个进行中的 pull request 的标题上添加前缀 `WIP:` 或者 `[WIP]`(此处大小写敏感)来防止它被意外合并,具体的前缀设置可以在配置文件 `app.ini` 中找到:
2323

@@ -28,6 +28,6 @@ WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP]
2828

2929
列表的第一个值将用于 helpers 程序。
3030

31-
## Pull Request 模板
31+
## 合并请求模板
3232

33-
有关 pull request 模板的更多信息请您移步 : [Issue and Pull Request templates](../issue-pull-request-templates)
33+
有关合并请求模板的更多信息请您移步 : [工单与合并请求模板](issue-pull-request-templates)

docs/content/doc/usage/push.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date: "2020-07-06T16:00:00+02:00"
3-
title: "Usage: Push"
3+
title: "Push"
44
slug: "push"
55
weight: 15
66
toc: false

modules/context/context.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ func (ctx *Context) TrHTMLEscapeArgs(msg string, args ...string) string {
6868
return ctx.Locale.Tr(msg, trArgs...)
6969
}
7070

71-
type contextKeyType struct{}
71+
type webContextKeyType struct{}
7272

73-
var contextKey interface{} = contextKeyType{}
73+
var WebContextKey = webContextKeyType{}
7474

75-
func GetContext(req *http.Request) *Context {
76-
ctx, _ := req.Context().Value(contextKey).(*Context)
75+
func GetWebContext(req *http.Request) *Context {
76+
ctx, _ := req.Context().Value(WebContextKey).(*Context)
7777
return ctx
7878
}
7979

@@ -86,7 +86,7 @@ type ValidateContext struct {
8686
func GetValidateContext(req *http.Request) (ctx *ValidateContext) {
8787
if ctxAPI, ok := req.Context().Value(apiContextKey).(*APIContext); ok {
8888
ctx = &ValidateContext{Base: ctxAPI.Base}
89-
} else if ctxWeb, ok := req.Context().Value(contextKey).(*Context); ok {
89+
} else if ctxWeb, ok := req.Context().Value(WebContextKey).(*Context); ok {
9090
ctx = &ValidateContext{Base: ctxWeb.Base}
9191
} else {
9292
panic("invalid context, expect either APIContext or Context")
@@ -135,7 +135,7 @@ func Contexter() func(next http.Handler) http.Handler {
135135
ctx.PageData = map[string]any{}
136136
ctx.Data["PageData"] = ctx.PageData
137137

138-
ctx.Base.AppendContextValue(contextKey, ctx)
138+
ctx.Base.AppendContextValue(WebContextKey, ctx)
139139
ctx.Base.AppendContextValueFunc(git.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
140140

141141
ctx.Csrf = PrepareCSRFProtector(csrfOpts, ctx)

modules/context/package.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func PackageContexter() func(next http.Handler) http.Handler {
150150
}
151151
defer baseCleanUp()
152152

153-
ctx.Base.AppendContextValue(contextKey, ctx)
153+
ctx.Base.AppendContextValue(WebContextKey, ctx)
154154
next.ServeHTTP(ctx.Resp, ctx.Req)
155155
})
156156
}

modules/git/git.go

+8
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ func syncGitConfig() (err error) {
224224
return fmt.Errorf("unable to prepare git home directory %s, err: %w", HomeDir(), err)
225225
}
226226

227+
// first, write user's git config options to git config file
228+
// user config options could be overwritten by builtin values later, because if a value is builtin, it must have some special purposes
229+
for k, v := range setting.GitConfig.Options {
230+
if err = configSet(strings.ToLower(k), v); err != nil {
231+
return err
232+
}
233+
}
234+
227235
// Git requires setting user.name and user.email in order to commit changes - old comment: "if they're not set just add some defaults"
228236
// TODO: need to confirm whether users really need to change these values manually. It seems that these values are dummy only and not really used.
229237
// If these values are not really used, then they can be set (overwritten) directly without considering about existence.

modules/git/git_test.go

+18-6
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ func TestMain(m *testing.M) {
4242
}
4343
}
4444

45-
func TestGitConfig(t *testing.T) {
46-
gitConfigContains := func(sub string) bool {
47-
if b, err := os.ReadFile(HomeDir() + "/.gitconfig"); err == nil {
48-
return strings.Contains(string(b), sub)
49-
}
50-
return false
45+
func gitConfigContains(sub string) bool {
46+
if b, err := os.ReadFile(HomeDir() + "/.gitconfig"); err == nil {
47+
return strings.Contains(string(b), sub)
5148
}
49+
return false
50+
}
5251

52+
func TestGitConfig(t *testing.T) {
5353
assert.False(t, gitConfigContains("key-a"))
5454

5555
assert.NoError(t, configSetNonExist("test.key-a", "val-a"))
@@ -81,3 +81,15 @@ func TestGitConfig(t *testing.T) {
8181
assert.NoError(t, configUnsetAll("test.key-x", "*"))
8282
assert.False(t, gitConfigContains("key-x = *"))
8383
}
84+
85+
func TestSyncConfig(t *testing.T) {
86+
oldGitConfig := setting.GitConfig
87+
defer func() {
88+
setting.GitConfig = oldGitConfig
89+
}()
90+
91+
setting.GitConfig.Options["sync-test.cfg-key-a"] = "CfgValA"
92+
assert.NoError(t, syncGitConfig())
93+
assert.True(t, gitConfigContains("[sync-test]"))
94+
assert.True(t, gitConfigContains("cfg-key-a = CfgValA"))
95+
}

modules/log/logger_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func TestLoggerPause(t *testing.T) {
9494
logger.AddWriters(w1)
9595

9696
GetManager().PauseAll()
97+
time.Sleep(50 * time.Millisecond)
9798

9899
logger.Info("info-level")
99100
time.Sleep(100 * time.Millisecond)

0 commit comments

Comments
 (0)