Skip to content

Commit b3fe0a7

Browse files
committed
Merge branch 'main' into lunny/remove_unused_translation_key
2 parents 7a1a8a9 + 8df59fa commit b3fe0a7

File tree

674 files changed

+7709
-5031
lines changed

Some content is hidden

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

674 files changed

+7709
-5031
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"version": "lts"
88
},
99
"ghcr.io/devcontainers/features/git-lfs:1.2.2": {},
10-
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
10+
"ghcr.io/devcontainers-extra/features/poetry:2": {},
1111
"ghcr.io/devcontainers/features/python:1": {
1212
"version": "3.12"
1313
},

.golangci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ linters:
4545
desc: do not use the ini package, use gitea's config system instead
4646
- pkg: gitea.com/go-chi/cache
4747
desc: do not use the go-chi cache package, use gitea's cache system
48+
nolintlint:
49+
allow-unused: false
50+
require-explanation: true
51+
require-specific: true
4852
gocritic:
4953
disabled-checks:
5054
- ifElseChain
@@ -83,6 +87,10 @@ linters:
8387
- name: unreachable-code
8488
- name: var-declaration
8589
- name: var-naming
90+
arguments:
91+
- [] # AllowList - do not remove as args for the rule are positional and won't work without lists first
92+
- [] # DenyList
93+
- - skip-package-name-checks: true # supress errors from underscore in migration packages
8694
staticcheck:
8795
checks:
8896
- all

Makefile

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ COMMA := ,
2626
XGO_VERSION := go-1.24.x
2727

2828
AIR_PACKAGE ?= github.com/air-verse/air@v1
29-
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.2.1
30-
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.7.0
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2
29+
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
30+
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.8.0
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
33-
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.6.0
34-
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0
33+
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.7.0
34+
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.32.3
3535
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
3636
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
3737
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
3838
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1
39-
GOPLS_PACKAGE ?= golang.org/x/tools/[email protected]
39+
GOPLS_PACKAGE ?= golang.org/x/tools/[email protected]
40+
GOPLS_MODERNIZE_PACKAGE ?= golang.org/x/tools/gopls/internal/analysis/modernize/cmd/[email protected]
4041

4142
DOCKER_IMAGE ?= gitea/gitea
4243
DOCKER_TAG ?= latest
@@ -80,7 +81,6 @@ ifeq ($(RACE_ENABLED),true)
8081
endif
8182

8283
STORED_VERSION_FILE := VERSION
83-
HUGO_VERSION ?= 0.111.3
8484

8585
GITHUB_REF_TYPE ?= branch
8686
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
@@ -230,7 +230,7 @@ clean: ## delete backend and integration files
230230
tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/
231231

232232
.PHONY: fmt
233-
fmt: ## format the Go code
233+
fmt: ## format the Go and template code
234234
@GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
235235
$(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl'))
236236
@# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only
@@ -249,6 +249,19 @@ fmt-check: fmt
249249
exit 1; \
250250
fi
251251

252+
.PHONY: fix
253+
fix: ## apply automated fixes to Go code
254+
$(GO) run $(GOPLS_MODERNIZE_PACKAGE) -fix ./...
255+
256+
.PHONY: fix-check
257+
fix-check: fix
258+
@diff=$$(git diff --color=always $(GO_SOURCES)); \
259+
if [ -n "$$diff" ]; then \
260+
echo "Please run 'make fix' and commit the result:"; \
261+
printf "%s" "$${diff}"; \
262+
exit 1; \
263+
fi
264+
252265
.PHONY: $(TAGS_EVIDENCE)
253266
$(TAGS_EVIDENCE):
254267
@mkdir -p $(MAKE_EVIDENCE_DIR)
@@ -288,7 +301,7 @@ checks: checks-frontend checks-backend ## run various consistency checks
288301
checks-frontend: lockfile-check svg-check ## check frontend files
289302

290303
.PHONY: checks-backend
291-
checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check ## check backend files
304+
checks-backend: tidy-check swagger-check fmt-check fix-check swagger-validate security-check ## check backend files
292305

293306
.PHONY: lint
294307
lint: lint-frontend lint-backend lint-spell ## lint everything
@@ -809,6 +822,7 @@ deps-tools: ## install tool dependencies
809822
$(GO) install $(GOVULNCHECK_PACKAGE) & \
810823
$(GO) install $(ACTIONLINT_PACKAGE) & \
811824
$(GO) install $(GOPLS_PACKAGE) & \
825+
$(GO) install $(GOPLS_MODERNIZE_PACKAGE) & \
812826
wait
813827

814828
node_modules: package-lock.json

cmd/embedded.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,14 @@ func collectAssetFilesByPattern(c *cli.Command, globs []glob.Glob, path string,
295295
}
296296
}
297297

298-
func compileCollectPatterns(args []string) ([]glob.Glob, error) {
298+
func compileCollectPatterns(args []string) (_ []glob.Glob, err error) {
299299
if len(args) == 0 {
300300
args = []string{"**"}
301301
}
302302
pat := make([]glob.Glob, len(args))
303303
for i := range args {
304-
if g, err := glob.Compile(args[i], '/'); err != nil {
305-
return nil, fmt.Errorf("'%s': Invalid glob pattern: %w", args[i], err)
306-
} else { //nolint:revive
307-
pat[i] = g
304+
if pat[i], err = glob.Compile(args[i], '/'); err != nil {
305+
return nil, fmt.Errorf("invalid glob patterh %q: %w", args[i], err)
308306
}
309307
}
310308
return pat, nil

contrib/backport/backport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
//nolint:forbidigo
4+
//nolint:forbidigo // use of print functions is allowed in cli
55
package main
66

77
import (

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ require (
5151
github.com/gliderlabs/ssh v0.3.8
5252
github.com/go-ap/activitypub v0.0.0-20250409143848-7113328b1f3d
5353
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73
54-
github.com/go-chi/chi/v5 v5.2.1
54+
github.com/go-chi/chi/v5 v5.2.2
5555
github.com/go-chi/cors v1.2.1
5656
github.com/go-co-op/gocron v1.37.0
5757
github.com/go-enry/go-enry/v2 v2.9.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73/go.mod h1:jyveZeGw5La
289289
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 h1:BP4M0CvQ4S3TGls2FvczZtj5Re/2ZzkV9VwqPHH/3Bo=
290290
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
291291
github.com/go-chi/chi/v5 v5.0.1/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
292-
github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8=
293-
github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
292+
github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618=
293+
github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
294294
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
295295
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
296296
github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0=

models/actions/run.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, err
166166
return nil, fmt.Errorf("event %s is not a pull request event", run.Event)
167167
}
168168

169+
func (run *ActionRun) GetWorkflowRunEventPayload() (*api.WorkflowRunPayload, error) {
170+
if run.Event == webhook_module.HookEventWorkflowRun {
171+
var payload api.WorkflowRunPayload
172+
if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil {
173+
return nil, err
174+
}
175+
return &payload, nil
176+
}
177+
return nil, fmt.Errorf("event %s is not a workflow run event", run.Event)
178+
}
179+
169180
func (run *ActionRun) IsSchedule() bool {
170181
return run.ScheduleID > 0
171182
}

models/actions/run_job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ func AggregateJobStatus(jobs []*ActionRunJob) Status {
185185
return StatusSuccess
186186
case hasCancelled:
187187
return StatusCancelled
188-
case hasFailure:
189-
return StatusFailure
190188
case hasRunning:
191189
return StatusRunning
190+
case hasFailure:
191+
return StatusFailure
192192
case hasWaiting:
193193
return StatusWaiting
194194
case hasBlocked:

models/actions/run_job_list.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,31 @@ type FindRunJobOptions struct {
8080
func (opts FindRunJobOptions) ToConds() builder.Cond {
8181
cond := builder.NewCond()
8282
if opts.RunID > 0 {
83-
cond = cond.And(builder.Eq{"run_id": opts.RunID})
83+
cond = cond.And(builder.Eq{"`action_run_job`.run_id": opts.RunID})
8484
}
8585
if opts.RepoID > 0 {
86-
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
87-
}
88-
if opts.OwnerID > 0 {
89-
cond = cond.And(builder.Eq{"owner_id": opts.OwnerID})
86+
cond = cond.And(builder.Eq{"`action_run_job`.repo_id": opts.RepoID})
9087
}
9188
if opts.CommitSHA != "" {
92-
cond = cond.And(builder.Eq{"commit_sha": opts.CommitSHA})
89+
cond = cond.And(builder.Eq{"`action_run_job`.commit_sha": opts.CommitSHA})
9390
}
9491
if len(opts.Statuses) > 0 {
95-
cond = cond.And(builder.In("status", opts.Statuses))
92+
cond = cond.And(builder.In("`action_run_job`.status", opts.Statuses))
9693
}
9794
if opts.UpdatedBefore > 0 {
98-
cond = cond.And(builder.Lt{"updated": opts.UpdatedBefore})
95+
cond = cond.And(builder.Lt{"`action_run_job`.updated": opts.UpdatedBefore})
9996
}
10097
return cond
10198
}
99+
100+
func (opts FindRunJobOptions) ToJoins() []db.JoinFunc {
101+
if opts.OwnerID > 0 {
102+
return []db.JoinFunc{
103+
func(sess db.Engine) error {
104+
sess.Join("INNER", "repository", "repository.id = repo_id AND repository.owner_id = ?", opts.OwnerID)
105+
return nil
106+
},
107+
}
108+
}
109+
return nil
110+
}

0 commit comments

Comments
 (0)