Skip to content

Commit cbf68b6

Browse files
committed
Merge remote-tracking branch 'upstream/main' into locale-cleanup
2 parents 3420d76 + 82e102f commit cbf68b6

File tree

215 files changed

+4989
-3221
lines changed

Some content is hidden

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

215 files changed

+4989
-3221
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
},
99
"ghcr.io/devcontainers/features/git-lfs:1.1.0": {},
1010
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
11-
"ghcr.io/devcontainers/features/python:1": {}
11+
"ghcr.io/devcontainers/features/python:1": {
12+
"version": "3.12"
13+
}
1214
},
1315
"customizations": {
1416
"vscode": {

.github/workflows/files-changed.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
- "Makefile"
4949
- ".golangci.yml"
5050
- ".editorconfig"
51+
- "options/locale/locale_en-US.ini"
5152
5253
frontend:
5354
- "**/*.js"

.github/workflows/pull-db-tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ jobs:
4949
- run: make backend
5050
env:
5151
TAGS: bindata
52-
- run: make test-pgsql-migration test-pgsql
52+
- name: run migration tests
53+
run: make test-pgsql-migration
54+
- name: run tests
55+
run: make test-pgsql
5356
timeout-minutes: 50
5457
env:
5558
TAGS: bindata gogit
@@ -72,7 +75,10 @@ jobs:
7275
- run: make backend
7376
env:
7477
TAGS: bindata gogit sqlite sqlite_unlock_notify
75-
- run: make test-sqlite-migration test-sqlite
78+
- name: run migration tests
79+
run: make test-sqlite-migration
80+
- name: run tests
81+
run: make test-sqlite
7682
timeout-minutes: 50
7783
env:
7884
TAGS: bindata gogit sqlite sqlite_unlock_notify
@@ -175,8 +181,10 @@ jobs:
175181
- run: make backend
176182
env:
177183
TAGS: bindata
184+
- name: run migration tests
185+
run: make test-mysql-migration
178186
- name: run tests
179-
run: make test-mysql-migration integration-test-coverage
187+
run: make integration-test-coverage
180188
env:
181189
TAGS: bindata
182190
RACE_ENABLED: true
@@ -208,7 +216,9 @@ jobs:
208216
- run: make backend
209217
env:
210218
TAGS: bindata
211-
- run: make test-mssql-migration test-mssql
219+
- run: make test-mssql-migration
220+
- name: run tests
221+
run: make test-mssql
212222
timeout-minutes: 50
213223
env:
214224
TAGS: bindata

Makefile

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
115115

116116
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
117117
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
118+
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
118119

119120
FOMANTIC_WORK_DIR := web_src/fomantic
120121

@@ -147,6 +148,7 @@ GO_DIRS := build cmd models modules routers services tests
147148
WEB_DIRS := web_src/js web_src/css
148149

149150
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github
151+
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
150152

151153
GO_SOURCES := $(wildcard *.go)
152154
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/options/bindata.go ! -path modules/public/bindata.go ! -path modules/templates/bindata.go)
@@ -426,7 +428,7 @@ lint-go-vet:
426428

427429
.PHONY: lint-editorconfig
428430
lint-editorconfig:
429-
$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates .github/workflows
431+
@$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES)
430432

431433
.PHONY: lint-actions
432434
lint-actions:
@@ -709,40 +711,31 @@ migrations.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
709711

710712
.PHONY: migrations.individual.mysql.test
711713
migrations.individual.mysql.test: $(GO_SOURCES)
712-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
713-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
714-
done
714+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
715715

716716
.PHONY: migrations.individual.sqlite.test\#%
717717
migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
718718
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
719719

720720
.PHONY: migrations.individual.pgsql.test
721721
migrations.individual.pgsql.test: $(GO_SOURCES)
722-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
723-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
724-
done
722+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
725723

726724
.PHONY: migrations.individual.pgsql.test\#%
727725
migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql
728726
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
729727

730-
731728
.PHONY: migrations.individual.mssql.test
732729
migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql
733-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
734-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg -test.failfast; \
735-
done
730+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
736731

737732
.PHONY: migrations.individual.mssql.test\#%
738733
migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql
739734
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
740735

741736
.PHONY: migrations.individual.sqlite.test
742737
migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
743-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
744-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
745-
done
738+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
746739

747740
.PHONY: migrations.individual.sqlite.test\#%
748741
migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
@@ -908,6 +901,7 @@ fomantic:
908901
cd $(FOMANTIC_WORK_DIR) && npm install --no-save
909902
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
910903
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
904+
$(SED_INPLACE) -e 's/ overrideBrowserslist\r/ overrideBrowserslist: ["defaults"]\r/g' $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/tasks/config/tasks.js
911905
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
912906
# fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event
913907
$(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js

docs/content/contributing/guidelines-frontend.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h
4747
9. Avoid unnecessary `!important` in CSS, add comments to explain why it's necessary if it can't be avoided.
4848
10. Avoid mixing different events in one event listener, prefer to use individual event listeners for every event.
4949
11. Custom event names are recommended to use `ce-` prefix.
50-
12. Gitea's tailwind-style CSS classes use `gt-` prefix (`gt-relative`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`).
50+
12. Prefer using Tailwind CSS which is available via `tw-` prefix, e.g. `tw-relative`. Gitea's helper CSS classes use `gt-` prefix (`gt-df`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`).
5151
13. Avoid inline scripts & styles as much as possible, it's recommended to put JS code into JS files and use CSS classes. If inline scripts & styles are unavoidable, explain the reason why it can't be avoided.
5252

5353
### Accessibility / ARIA

docs/content/contributing/guidelines-frontend.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ HTML 页面由[Go HTML Template](https://pkg.go.dev/html/template)渲染。
4747
9. 避免在 CSS 中使用不必要的`!important`,如果无法避免,添加注释解释为什么需要它。
4848
10. 避免在一个事件监听器中混合不同的事件,优先为每个事件使用独立的事件监听器。
4949
11. 推荐使用自定义事件名称前缀`ce-`
50-
12. Gitea 的 tailwind-style CSS 类使用`gt-`前缀(`gt-relative`),Gitea 自身的私有框架级 CSS 类使用`g-`前缀(`g-modal-confirm`)。
50+
12. 建议使用 Tailwind CSS,它可以通过 `tw-` 前缀获得,例如 `tw-relative`. Gitea 自身的助手类 CSS 使用 `gt-` 前缀(`gt-df`),Gitea 自身的私有框架级 CSS 类使用 `g-` 前缀(`g-modal-confirm`)。
5151
13. 尽量避免内联脚本和样式,建议将JS代码放入JS文件中并使用CSS类。如果内联脚本和样式不可避免,请解释无法避免的原因。
5252

5353
### 可访问性 / ARIA

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ require (
4949
github.com/go-ldap/ldap/v3 v3.4.6
5050
github.com/go-sql-driver/mysql v1.7.1
5151
github.com/go-swagger/go-swagger v0.30.5
52-
github.com/go-testfixtures/testfixtures/v3 v3.9.0
52+
github.com/go-testfixtures/testfixtures/v3 v3.10.0
5353
github.com/go-webauthn/webauthn v0.10.0
5454
github.com/gobwas/glob v0.2.3
5555
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
5656
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
5757
github.com/golang-jwt/jwt/v5 v5.2.0
5858
github.com/google/go-github/v57 v57.0.0
5959
github.com/google/pprof v0.0.0-20240117000934-35fc243c5815
60-
github.com/google/uuid v1.5.0
60+
github.com/google/uuid v1.6.0
6161
github.com/gorilla/feeds v1.1.2
6262
github.com/gorilla/sessions v1.2.2
6363
github.com/hashicorp/go-version v1.6.0
@@ -73,7 +73,7 @@ require (
7373
github.com/lib/pq v1.10.9
7474
github.com/markbates/goth v1.78.0
7575
github.com/mattn/go-isatty v0.0.20
76-
github.com/mattn/go-sqlite3 v1.14.19
76+
github.com/mattn/go-sqlite3 v1.14.22
7777
github.com/meilisearch/meilisearch-go v0.26.1
7878
github.com/mholt/archiver/v3 v3.5.1
7979
github.com/microcosm-cc/bluemonday v1.0.26
@@ -113,7 +113,7 @@ require (
113113
golang.org/x/text v0.14.0
114114
golang.org/x/tools v0.17.0
115115
google.golang.org/grpc v1.60.1
116-
google.golang.org/protobuf v1.32.0
116+
google.golang.org/protobuf v1.33.0
117117
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
118118
gopkg.in/ini.v1 v1.67.0
119119
gopkg.in/yaml.v3 v3.0.1
@@ -129,7 +129,7 @@ require (
129129
dario.cat/mergo v1.0.0 // indirect
130130
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 // indirect
131131
github.com/ClickHouse/ch-go v0.61.1 // indirect
132-
github.com/ClickHouse/clickhouse-go/v2 v2.17.1 // indirect
132+
github.com/ClickHouse/clickhouse-go/v2 v2.18.0 // indirect
133133
github.com/DataDog/zstd v1.5.5 // indirect
134134
github.com/Masterminds/goutils v1.1.1 // indirect
135135
github.com/Masterminds/semver/v3 v3.2.1 // indirect
@@ -241,7 +241,7 @@ require (
241241
github.com/oklog/ulid v1.3.1 // indirect
242242
github.com/olekukonko/tablewriter v0.0.5 // indirect
243243
github.com/onsi/ginkgo v1.16.5 // indirect
244-
github.com/paulmach/orb v0.11.0 // indirect
244+
github.com/paulmach/orb v0.11.1 // indirect
245245
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
246246
github.com/pierrec/lz4/v4 v4.1.21 // indirect
247247
github.com/pjbgf/sha1cd v0.3.0 // indirect
@@ -302,7 +302,7 @@ replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1
302302

303303
replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142115-2c99e1ffdfa0
304304

305-
replace github.com/nektos/act => gitea.com/gitea/act v0.2.51
305+
replace github.com/nektos/act => gitea.com/gitea/act v0.259.1
306306

307307
replace github.com/gorilla/feeds => github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5
308308

go.sum

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
4848
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
4949
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
5050
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
51-
gitea.com/gitea/act v0.2.51 h1:gXc/B4OlTciTTzAx9cmNyw04n2SDO7exPjAsR5Idu+c=
52-
gitea.com/gitea/act v0.2.51/go.mod h1:CoaX2053jqBlD6JMgu4d4UgFL/rp2I14Kt5mMqcs0Z0=
51+
gitea.com/gitea/act v0.259.1 h1:8GG1o/xtUHl3qjn5f0h/2FXrT5ubBn05TJOM5ry+FBw=
52+
gitea.com/gitea/act v0.259.1/go.mod h1:UxZWRYqQG2Yj4+4OqfGWW5a3HELwejyWFQyU7F1jUD8=
5353
gitea.com/go-chi/binding v0.0.0-20230415142243-04b515c6d669 h1:RUBX+MK/TsDxpHmymaOaydfigEbbzqUnG1OTZU/HAeo=
5454
gitea.com/go-chi/binding v0.0.0-20230415142243-04b515c6d669/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc=
5555
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=
@@ -78,8 +78,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
7878
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
7979
github.com/ClickHouse/ch-go v0.61.1 h1:j5rx3qnvcnYjhnP1IdXE/vdIRQiqgwAzyqOaasA6QCw=
8080
github.com/ClickHouse/ch-go v0.61.1/go.mod h1:myxt/JZgy2BYHFGQqzmaIpbfr5CMbs3YHVULaWQj5YU=
81-
github.com/ClickHouse/clickhouse-go/v2 v2.17.1 h1:ZCmAYWpu75IyEi7+Yrs/uaAjiCGY5wfW5kXo64exkX4=
82-
github.com/ClickHouse/clickhouse-go/v2 v2.17.1/go.mod h1:rkGTvFDTLqLIm0ma+13xmcCfr/08Gvs7KmFt1tgiWHQ=
81+
github.com/ClickHouse/clickhouse-go/v2 v2.18.0 h1:O1LicIeg2JS2V29fKRH4+yT3f6jvvcJBm506dpVQ4mQ=
82+
github.com/ClickHouse/clickhouse-go/v2 v2.18.0/go.mod h1:ztQvX6wm7kAbhJslS87EXEhOVNY/TObXwyURnGju5FQ=
8383
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
8484
github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
8585
github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
@@ -384,8 +384,8 @@ github.com/go-swagger/scan-repo-boundary v0.0.0-20180623220736-973b3573c013/go.m
384384
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
385385
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
386386
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
387-
github.com/go-testfixtures/testfixtures/v3 v3.9.0 h1:938g5V+GWLVejm3Hc+nWCuEXRlcglZDDlN/t1gWzcSY=
388-
github.com/go-testfixtures/testfixtures/v3 v3.9.0/go.mod h1:cdsKD2ApFBjdog9jRsz6EJqF+LClq/hrwE9K/1Dzo4s=
387+
github.com/go-testfixtures/testfixtures/v3 v3.10.0 h1:BrBwN7AuC+74g5qtk9D59TLGOaEa8Bw1WmIsf+SyzWc=
388+
github.com/go-testfixtures/testfixtures/v3 v3.10.0/go.mod h1:z8RoleoNtibi6Ar8ziCW7e6PQ+jWiqbUWvuv8AMe4lo=
389389
github.com/go-webauthn/webauthn v0.10.0 h1:yuW2e1tXnRAwAvKrR4q4LQmc6XtCMH639/ypZGhZCwk=
390390
github.com/go-webauthn/webauthn v0.10.0/go.mod h1:l0NiauXhL6usIKqNLCUM3Qir43GK7ORg8ggold0Uv/Y=
391391
github.com/go-webauthn/x v0.1.6 h1:QNAX+AWeqRt9loE8mULeWJCqhVG5D/jvdmJ47fIWCkQ=
@@ -488,8 +488,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
488488
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
489489
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
490490
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
491-
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
492-
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
491+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
492+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
493493
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
494494
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
495495
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
@@ -643,8 +643,8 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m
643643
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
644644
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
645645
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
646-
github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI=
647-
github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
646+
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
647+
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
648648
github.com/meilisearch/meilisearch-go v0.26.1 h1:3bmo2uLijX7kvBmiZ9LupVfC95TFcRJDgrRTzbOoE4A=
649649
github.com/meilisearch/meilisearch-go v0.26.1/go.mod h1:SxuSqDcPBIykjWz1PX+KzsYzArNLSCadQodWs8extS0=
650650
github.com/mholt/acmez v1.2.0 h1:1hhLxSgY5FvH5HCnGUuwbKY2VQVo8IU7rxXKSnZ7F30=
@@ -718,8 +718,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
718718
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
719719
github.com/opencontainers/image-spec v1.1.0-rc6 h1:XDqvyKsJEbRtATzkgItUqBA7QHk58yxX1Ov9HERHNqU=
720720
github.com/opencontainers/image-spec v1.1.0-rc6/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
721-
github.com/paulmach/orb v0.11.0 h1:JfVXJUBeH9ifc/OrhBY0lL16QsmPgpCHMlqSSYhcgAA=
722-
github.com/paulmach/orb v0.11.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU=
721+
github.com/paulmach/orb v0.11.1 h1:3koVegMC4X/WeiXYz9iswopaTwMem53NzTJuTF20JzU=
722+
github.com/paulmach/orb v0.11.1/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU=
723723
github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
724724
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
725725
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
@@ -1308,8 +1308,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
13081308
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
13091309
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
13101310
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1311-
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
1312-
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
1311+
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
1312+
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
13131313
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
13141314
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
13151315
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

models/actions/variable.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strings"
1111

1212
"code.gitea.io/gitea/models/db"
13+
"code.gitea.io/gitea/modules/log"
1314
"code.gitea.io/gitea/modules/timeutil"
1415
"code.gitea.io/gitea/modules/util"
1516

@@ -82,3 +83,35 @@ func UpdateVariable(ctx context.Context, variable *ActionVariable) (bool, error)
8283
})
8384
return count != 0, err
8485
}
86+
87+
func GetVariablesOfRun(ctx context.Context, run *ActionRun) (map[string]string, error) {
88+
variables := map[string]string{}
89+
90+
// Global
91+
globalVariables, err := db.Find[ActionVariable](ctx, FindVariablesOpts{})
92+
if err != nil {
93+
log.Error("find global variables: %v", err)
94+
return nil, err
95+
}
96+
97+
// Org / User level
98+
ownerVariables, err := db.Find[ActionVariable](ctx, FindVariablesOpts{OwnerID: run.Repo.OwnerID})
99+
if err != nil {
100+
log.Error("find variables of org: %d, error: %v", run.Repo.OwnerID, err)
101+
return nil, err
102+
}
103+
104+
// Repo level
105+
repoVariables, err := db.Find[ActionVariable](ctx, FindVariablesOpts{RepoID: run.RepoID})
106+
if err != nil {
107+
log.Error("find variables of repo: %d, error: %v", run.RepoID, err)
108+
return nil, err
109+
}
110+
111+
// Level precedence: Repo > Org / User > Global
112+
for _, v := range append(globalVariables, append(ownerVariables, repoVariables...)...) {
113+
variables[v.Name] = v.Data
114+
}
115+
116+
return variables, nil
117+
}

0 commit comments

Comments
 (0)