Skip to content

Commit 453c63d

Browse files
committed
Merge remote-tracking branch 'origin/main' into notext
* origin/main: Interpolate runs-on with variables when scheduling tasks (go-gitea#30640) Initial support for colorblindness-friendly themes (go-gitea#30625) Fix flash message for flex-container (go-gitea#30657) Perform Newest sort type correctly when sorting issues (go-gitea#30644) Fix project name wrapping, remove horizontal margin on header (go-gitea#30631) Add a db consistency check to remove runners that do not belong to a repository (go-gitea#30614) Fix wrong table name (go-gitea#30557) Fix compare api swagger (go-gitea#30648) [skip ci] Updated translations via Crowdin Fix queue test (go-gitea#30646) Enable jquery-related eslint rules that have no violations (go-gitea#30632) Enable more `revive` linter rules (go-gitea#30608) Remove obsolete CSS text classes (go-gitea#30576) Hide diff stats on empty PRs (go-gitea#30629) [skip ci] Updated licenses and gitignores Use correct hash for "git update-index" (go-gitea#30626) Fix repo home UI when there is no repo description (go-gitea#30552) Fix dropdown text ellipsis (go-gitea#30628) fix(api): refactor branch and tag existence checks (go-gitea#30618) Add --skip-db option to dump command (go-gitea#30613)
2 parents d0303ff + 2f6b1c4 commit 453c63d

File tree

166 files changed

+535
-495
lines changed

Some content is hidden

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

166 files changed

+535
-495
lines changed

.eslintrc.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ rules:
310310
jquery/no-merge: [2]
311311
jquery/no-param: [2]
312312
jquery/no-parent: [0]
313-
jquery/no-parents: [0]
313+
jquery/no-parents: [2]
314314
jquery/no-parse-html: [2]
315315
jquery/no-prop: [2]
316316
jquery/no-proxy: [2]
@@ -319,8 +319,8 @@ rules:
319319
jquery/no-show: [2]
320320
jquery/no-size: [2]
321321
jquery/no-sizzle: [2]
322-
jquery/no-slide: [0]
323-
jquery/no-submit: [0]
322+
jquery/no-slide: [2]
323+
jquery/no-submit: [2]
324324
jquery/no-text: [2]
325325
jquery/no-toggle: [2]
326326
jquery/no-trigger: [0]
@@ -458,7 +458,7 @@ rules:
458458
no-jquery/no-other-utils: [2]
459459
no-jquery/no-param: [2]
460460
no-jquery/no-parent: [0]
461-
no-jquery/no-parents: [0]
461+
no-jquery/no-parents: [2]
462462
no-jquery/no-parse-html-literal: [0]
463463
no-jquery/no-parse-html: [2]
464464
no-jquery/no-parse-json: [2]

.golangci.yml

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
linters:
2+
enable-all: false
3+
disable-all: true
4+
fast: false
25
enable:
36
- bidichk
4-
# - deadcode # deprecated - https://github.com/golangci/golangci-lint/issues/1841
57
- depguard
68
- dupl
79
- errcheck
810
- forbidigo
911
- gocritic
10-
# - gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
1112
- gofmt
1213
- gofumpt
1314
- gosimple
@@ -17,20 +18,18 @@ linters:
1718
- nolintlint
1819
- revive
1920
- staticcheck
20-
# - structcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
2121
- stylecheck
2222
- typecheck
2323
- unconvert
2424
- unused
25-
# - varcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
2625
- wastedassign
27-
enable-all: false
28-
disable-all: true
29-
fast: false
3026

3127
run:
3228
timeout: 10m
3329

30+
output:
31+
sort-results: true
32+
3433
linters-settings:
3534
stylecheck:
3635
checks: ["all", "-ST1005", "-ST1003"]
@@ -47,27 +46,37 @@ linters-settings:
4746
errorCode: 1
4847
warningCode: 1
4948
rules:
49+
- name: atomic
50+
- name: bare-return
5051
- name: blank-imports
52+
- name: constant-logical-expr
5153
- name: context-as-argument
5254
- name: context-keys-type
5355
- name: dot-imports
56+
- name: duplicated-imports
57+
- name: empty-lines
58+
- name: error-naming
5459
- name: error-return
5560
- name: error-strings
56-
- name: error-naming
61+
- name: errorf
5762
- name: exported
63+
- name: identical-branches
5864
- name: if-return
5965
- name: increment-decrement
60-
- name: var-naming
61-
- name: var-declaration
66+
- name: indent-error-flow
67+
- name: modifies-value-receiver
6268
- name: package-comments
6369
- name: range
6470
- name: receiver-naming
71+
- name: redefines-builtin-id
72+
- name: string-of-int
73+
- name: superfluous-else
6574
- name: time-naming
75+
- name: unconditional-recursion
6676
- name: unexported-return
67-
- name: indent-error-flow
68-
- name: errorf
69-
- name: duplicated-imports
70-
- name: modifies-value-receiver
77+
- name: unreachable-code
78+
- name: var-declaration
79+
- name: var-naming
7180
gofumpt:
7281
extra-rules: true
7382
depguard:
@@ -93,8 +102,8 @@ issues:
93102
max-issues-per-linter: 0
94103
max-same-issues: 0
95104
exclude-dirs: [node_modules, public, web_src]
105+
exclude-case-sensitive: true
96106
exclude-rules:
97-
# Exclude some linters from running on tests files.
98107
- path: _test\.go
99108
linters:
100109
- gocyclo
@@ -112,19 +121,19 @@ issues:
112121
- path: cmd
113122
linters:
114123
- forbidigo
115-
- linters:
124+
- text: "webhook"
125+
linters:
116126
- dupl
117-
text: "webhook"
118-
- linters:
127+
- text: "`ID' should not be capitalized"
128+
linters:
119129
- gocritic
120-
text: "`ID' should not be capitalized"
121-
- linters:
130+
- text: "swagger"
131+
linters:
122132
- unused
123133
- deadcode
124-
text: "swagger"
125-
- linters:
134+
- text: "argument x is overwritten before first use"
135+
linters:
126136
- staticcheck
127-
text: "argument x is overwritten before first use"
128137
- text: "commentFormatting: put a space between `//` and comment text"
129138
linters:
130139
- gocritic

cmd/dump.go

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ var CmdDump = &cli.Command{
8787
Name: "skip-index",
8888
Usage: "Skip bleve index data",
8989
},
90+
&cli.BoolFlag{
91+
Name: "skip-db",
92+
Usage: "Skip database",
93+
},
9094
&cli.StringFlag{
9195
Name: "type",
9296
Usage: fmt.Sprintf(`Dump output format, default to "zip", supported types: %s`, strings.Join(dump.SupportedOutputTypes, ", ")),
@@ -185,35 +189,41 @@ func runDump(ctx *cli.Context) error {
185189
}
186190
}
187191

188-
tmpDir := ctx.String("tempdir")
189-
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
190-
fatal("Path does not exist: %s", tmpDir)
191-
}
192+
if ctx.Bool("skip-db") {
193+
// Ensure that we don't dump the database file that may reside in setting.AppDataPath or elsewhere.
194+
dumper.GlobalExcludeAbsPath(setting.Database.Path)
195+
log.Info("Skipping database")
196+
} else {
197+
tmpDir := ctx.String("tempdir")
198+
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
199+
fatal("Path does not exist: %s", tmpDir)
200+
}
192201

193-
dbDump, err := os.CreateTemp(tmpDir, "gitea-db.sql")
194-
if err != nil {
195-
fatal("Failed to create tmp file: %v", err)
196-
}
197-
defer func() {
198-
_ = dbDump.Close()
199-
if err := util.Remove(dbDump.Name()); err != nil {
200-
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
202+
dbDump, err := os.CreateTemp(tmpDir, "gitea-db.sql")
203+
if err != nil {
204+
fatal("Failed to create tmp file: %v", err)
201205
}
202-
}()
206+
defer func() {
207+
_ = dbDump.Close()
208+
if err := util.Remove(dbDump.Name()); err != nil {
209+
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
210+
}
211+
}()
203212

204-
targetDBType := ctx.String("database")
205-
if len(targetDBType) > 0 && targetDBType != setting.Database.Type.String() {
206-
log.Info("Dumping database %s => %s...", setting.Database.Type, targetDBType)
207-
} else {
208-
log.Info("Dumping database...")
209-
}
213+
targetDBType := ctx.String("database")
214+
if len(targetDBType) > 0 && targetDBType != setting.Database.Type.String() {
215+
log.Info("Dumping database %s => %s...", setting.Database.Type, targetDBType)
216+
} else {
217+
log.Info("Dumping database...")
218+
}
210219

211-
if err := db.DumpDatabase(dbDump.Name(), targetDBType); err != nil {
212-
fatal("Failed to dump database: %v", err)
213-
}
220+
if err := db.DumpDatabase(dbDump.Name(), targetDBType); err != nil {
221+
fatal("Failed to dump database: %v", err)
222+
}
214223

215-
if err = dumper.AddFile("gitea-db.sql", dbDump.Name()); err != nil {
216-
fatal("Failed to include gitea-db.sql: %v", err)
224+
if err = dumper.AddFile("gitea-db.sql", dbDump.Name()); err != nil {
225+
fatal("Failed to include gitea-db.sql: %v", err)
226+
}
217227
}
218228

219229
log.Info("Adding custom configuration file from %s", setting.CustomConf)

cmd/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ func hookPrintResult(output, isCreate bool, branch, url string) {
465465
fmt.Fprintf(os.Stderr, " %s\n", url)
466466
}
467467
fmt.Fprintln(os.Stderr, "")
468-
os.Stderr.Sync()
468+
_ = os.Stderr.Sync()
469469
}
470470

471471
func pushOptions() map[string]string {

custom/conf/app.example.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,8 @@ LEVEL = Info
12311231
;DEFAULT_THEME = gitea-auto
12321232
;;
12331233
;; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`.
1234-
;THEMES = gitea-auto,gitea-light,gitea-dark
1234+
;; Leave it empty to allow users to select any theme from "{CustomPath}/public/assets/css/theme-*.css"
1235+
;THEMES =
12351236
;;
12361237
;; All available reactions users can choose on issues/prs and comments.
12371238
;; Values can be emoji alias (:smile:) or a unicode emoji.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a
214214
- `SITEMAP_PAGING_NUM`: **20**: Number of items that are displayed in a single subsitemap.
215215
- `GRAPH_MAX_COMMIT_NUM`: **100**: Number of maximum commits shown in the commit graph.
216216
- `CODE_COMMENT_LINES`: **4**: Number of line of codes shown for a code comment.
217-
- `DEFAULT_THEME`: **gitea-auto**: \[gitea-auto, gitea-light, gitea-dark\]: Set the default theme for the Gitea installation.
217+
- `DEFAULT_THEME`: **gitea-auto**: Set the default theme for the Gitea installation, custom themes could be provided by "{CustomPath}/public/assets/css/theme-*.css".
218218
- `SHOW_USER_EMAIL`: **true**: Whether the email of the user should be shown in the Explore Users page.
219-
- `THEMES`: **gitea-auto,gitea-light,gitea-dark**: All available themes. Allow users select personalized themes.
220-
regardless of the value of `DEFAULT_THEME`.
219+
- `THEMES`: **_empty_**: All available themes by "{CustomPath}/public/assets/css/theme-*.css". Allow users select personalized themes.
221220
- `MAX_DISPLAY_FILE_SIZE`: **8388608**: Max size of files to be displayed (default is 8MiB)
222221
- `AMBIGUOUS_UNICODE_DETECTION`: **true**: Detect ambiguous unicode characters in file contents and show warnings on the UI
223222
- `REACTIONS`: All available reactions users can choose on issues/prs and comments

docs/content/administration/config-cheat-sheet.zh-cn.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,9 @@ menu:
212212
- `SITEMAP_PAGING_NUM`: **20**: 在单个子SiteMap中显示的项数。
213213
- `GRAPH_MAX_COMMIT_NUM`: **100**: 提交图中显示的最大commit数量。
214214
- `CODE_COMMENT_LINES`: **4**: 在代码评论中能够显示的最大代码行数。
215-
- `DEFAULT_THEME`: **gitea-auto**: \[gitea-auto, gitea-light, gitea-dark\]: 在Gitea安装时候设置的默认主题
215+
- `DEFAULT_THEME`: **gitea-auto**: 在Gitea安装时候设置的默认主题,自定义的主题可以通过 "{CustomPath}/public/assets/css/theme-*.css" 提供
216216
- `SHOW_USER_EMAIL`: **true**: 用户的电子邮件是否应该显示在`Explore Users`页面中。
217-
- `THEMES`: **gitea-auto,gitea-light,gitea-dark**: 所有可用的主题。允许用户选择个性化的主题,
218-
而不受DEFAULT_THEME 值的影响。
217+
- `THEMES`: **_empty_**: 所有可用的主题(由 "{CustomPath}/public/assets/css/theme-*.css" 提供)。允许用户选择个性化的主题,
219218
- `MAX_DISPLAY_FILE_SIZE`: **8388608**: 能够显示文件的最大大小(默认为8MiB)。
220219
- `REACTIONS`: 用户可以在问题(Issue)、Pull Request(PR)以及评论中选择的所有可选的反应。
221220
这些值可以是表情符号别名(例如::smile:)或Unicode表情符号。

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ To make a custom theme available to all users:
381381
382382
1. Add a CSS file to `$GITEA_CUSTOM/public/assets/css/theme-<theme-name>.css`.
383383
The value of `$GITEA_CUSTOM` of your instance can be queried by calling `gitea help` and looking up the value of "CustomPath".
384-
2. Add `<theme-name>` to the comma-separated list of setting `THEMES` in `app.ini`
384+
2. Add `<theme-name>` to the comma-separated list of setting `THEMES` in `app.ini`, or leave `THEMES` empty to allow all themes.
385385
386386
Community themes are listed in [gitea/awesome-gitea#themes](https://gitea.com/gitea/awesome-gitea#themes).
387387

docs/content/help/faq.en-us.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,6 @@ At some point, a customer or third party needs access to a specific repo and onl
178178

179179
Use [Fail2Ban](administration/fail2ban-setup.md) to monitor and stop automated login attempts or other malicious behavior based on log patterns
180180

181-
## How to add/use custom themes
182-
183-
Gitea supports three official themes right now, `gitea-light`, `gitea-dark`, and `gitea-auto` (automatically switches between the previous two depending on operating system settings).
184-
To add your own theme, currently the only way is to provide a complete theme (not just color overrides)
185-
186-
As an example, let's say our theme is `arc-blue` (this is a real theme, and can be found [in this issue](https://github.com/go-gitea/gitea/issues/6011))
187-
188-
Name the `.css` file `theme-arc-blue.css` and add it to your custom folder in `custom/public/assets/css`
189-
190-
Allow users to use it by adding `arc-blue` to the list of `THEMES` in your `app.ini`
191-
192181
## SSHD vs built-in SSH
193182

194183
SSHD is the built-in SSH server on most Unix systems.

docs/content/help/faq.zh-cn.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,6 @@ Gitea不提供内置的Pages服务器。您需要一个专用的域名来提供
182182

183183
使用 [Fail2Ban](administration/fail2ban-setup.md) 监视并阻止基于日志模式的自动登录尝试或其他恶意行为。
184184

185-
## 如何添加/使用自定义主题
186-
187-
Gitea 目前支持三个官方主题,分别是 `gitea-light``gitea-dark``gitea-auto`(根据操作系统设置自动切换前两个主题)。
188-
要添加自己的主题,目前唯一的方法是提供一个完整的主题(不仅仅是颜色覆盖)。
189-
190-
假设我们的主题是 `arc-blue`(这是一个真实的主题,可以在[此问题](https://github.com/go-gitea/gitea/issues/6011)中找到)
191-
192-
`.css`文件命名为`theme-arc-blue.css`并将其添加到`custom/public/assets/css`文件夹中
193-
194-
通过将`arc-blue`添加到`app.ini`中的`THEMES`列表中,允许用户使用该主题
195-
196185
## SSHD vs 内建SSH
197186

198187
SSHD是大多数Unix系统上内建的SSH服务器。

models/actions/run.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,10 @@ func (run *ActionRun) LoadAttributes(ctx context.Context) error {
9898
return nil
9999
}
100100

101-
if run.Repo == nil {
102-
repo, err := repo_model.GetRepositoryByID(ctx, run.RepoID)
103-
if err != nil {
104-
return err
105-
}
106-
run.Repo = repo
101+
if err := run.LoadRepo(ctx); err != nil {
102+
return err
107103
}
104+
108105
if err := run.Repo.LoadAttributes(ctx); err != nil {
109106
return err
110107
}
@@ -120,6 +117,19 @@ func (run *ActionRun) LoadAttributes(ctx context.Context) error {
120117
return nil
121118
}
122119

120+
func (run *ActionRun) LoadRepo(ctx context.Context) error {
121+
if run == nil || run.Repo != nil {
122+
return nil
123+
}
124+
125+
repo, err := repo_model.GetRepositoryByID(ctx, run.RepoID)
126+
if err != nil {
127+
return err
128+
}
129+
run.Repo = repo
130+
return nil
131+
}
132+
123133
func (run *ActionRun) Duration() time.Duration {
124134
return calculateDuration(run.Started, run.Stopped, run.Status) + run.PreviousDuration
125135
}

0 commit comments

Comments
 (0)