Skip to content

Commit 4b88f93

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix a panic bug when head repository deleting (go-gitea#30674) Fix some bug on migrations (go-gitea#30647) Fix checkbox field markup (go-gitea#30666) Avoid doubled border for the PR info segment (go-gitea#30663) 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)
2 parents f607c27 + 8b36324 commit 4b88f93

File tree

163 files changed

+453
-422
lines changed

Some content is hidden

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

163 files changed

+453
-422
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: [0]
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/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
}

models/actions/runner.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func CountRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
270270
// Only affect action runners were a owner ID is set, as actions runners
271271
// could also be created on a repository.
272272
return db.GetEngine(ctx).Table("action_runner").
273-
Join("LEFT", "user", "`action_runner`.owner_id = `user`.id").
273+
Join("LEFT", "`user`", "`action_runner`.owner_id = `user`.id").
274274
Where("`action_runner`.owner_id != ?", 0).
275275
And(builder.IsNull{"`user`.id"}).
276276
Count(new(ActionRunner))
@@ -279,7 +279,7 @@ func CountRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
279279
func FixRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
280280
subQuery := builder.Select("`action_runner`.id").
281281
From("`action_runner`").
282-
Join("LEFT", "user", "`action_runner`.owner_id = `user`.id").
282+
Join("LEFT", "`user`", "`action_runner`.owner_id = `user`.id").
283283
Where(builder.Neq{"`action_runner`.owner_id": 0}).
284284
And(builder.IsNull{"`user`.id"})
285285
b := builder.Delete(builder.In("id", subQuery)).From("`action_runner`")
@@ -289,3 +289,25 @@ func FixRunnersWithoutBelongingOwner(ctx context.Context) (int64, error) {
289289
}
290290
return res.RowsAffected()
291291
}
292+
293+
func CountRunnersWithoutBelongingRepo(ctx context.Context) (int64, error) {
294+
return db.GetEngine(ctx).Table("action_runner").
295+
Join("LEFT", "`repository`", "`action_runner`.repo_id = `repository`.id").
296+
Where("`action_runner`.repo_id != ?", 0).
297+
And(builder.IsNull{"`repository`.id"}).
298+
Count(new(ActionRunner))
299+
}
300+
301+
func FixRunnersWithoutBelongingRepo(ctx context.Context) (int64, error) {
302+
subQuery := builder.Select("`action_runner`.id").
303+
From("`action_runner`").
304+
Join("LEFT", "`repository`", "`action_runner`.repo_id = `repository`.id").
305+
Where(builder.Neq{"`action_runner`.repo_id": 0}).
306+
And(builder.IsNull{"`repository`.id"})
307+
b := builder.Delete(builder.In("id", subQuery)).From("`action_runner`")
308+
res, err := db.GetEngine(ctx).Exec(b)
309+
if err != nil {
310+
return 0, err
311+
}
312+
return res.RowsAffected()
313+
}

models/actions/variable.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func DeleteVariable(ctx context.Context, id int64) error {
9292
func GetVariablesOfRun(ctx context.Context, run *ActionRun) (map[string]string, error) {
9393
variables := map[string]string{}
9494

95+
if err := run.LoadRepo(ctx); err != nil {
96+
log.Error("LoadRepo: %v", err)
97+
return nil, err
98+
}
99+
95100
// Global
96101
globalVariables, err := db.Find[ActionVariable](ctx, FindVariablesOpts{})
97102
if err != nil {

models/asymkey/gpg_key_commit_verification.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *CommitVerific
110110
Reason: "gpg.error.no_committer_account",
111111
}
112112
}
113-
114113
}
115114
}
116115

models/auth/oauth2_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"github.com/stretchr/testify/assert"
1414
)
1515

16-
//////////////////// Application
17-
1816
func TestOAuth2Application_GenerateClientSecret(t *testing.T) {
1917
assert.NoError(t, unittest.PrepareTestDatabase())
2018
app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})

models/db/engine.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ func NamesToBean(names ...string) ([]any, error) {
227227
// Need to map provided names to beans...
228228
beanMap := make(map[string]any)
229229
for _, bean := range tables {
230-
231230
beanMap[strings.ToLower(reflect.Indirect(reflect.ValueOf(bean)).Type().Name())] = bean
232231
beanMap[strings.ToLower(x.TableName(bean))] = bean
233232
beanMap[strings.ToLower(x.TableName(bean, true))] = bean

models/issues/review.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,9 @@ func CreateReview(ctx context.Context, opts CreateReviewOptions) (*Review, error
345345
return nil, err
346346
}
347347
}
348-
349348
} else if opts.ReviewerTeam != nil {
350349
review.Type = ReviewTypeRequest
351350
review.ReviewerTeamID = opts.ReviewerTeam.ID
352-
353351
} else {
354352
return nil, fmt.Errorf("provide either reviewer or reviewer team")
355353
}

0 commit comments

Comments
 (0)