Skip to content

Commit 2e787ea

Browse files
authored
Merge branch 'main' into lunny/optimaze_feed_count
2 parents 5f78cc8 + 4a7ab0a commit 2e787ea

File tree

345 files changed

+18339
-28068
lines changed

Some content is hidden

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

345 files changed

+18339
-28068
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Gitea DevContainer",
3-
"image": "mcr.microsoft.com/devcontainers/go:1.23-bookworm",
3+
"image": "mcr.microsoft.com/devcontainers/go:1.24-bookworm",
44
"features": {
55
// installs nodejs into container
66
"ghcr.io/devcontainers/features/node:1": {

.dockerignore

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,6 @@ cpu.out
7979
/public/assets/fonts
8080
/public/assets/img/avatar
8181
/vendor
82-
/web_src/fomantic/node_modules
83-
/web_src/fomantic/build/*
84-
!/web_src/fomantic/build/semantic.js
85-
!/web_src/fomantic/build/semantic.css
86-
!/web_src/fomantic/build/themes
87-
/web_src/fomantic/build/themes/*
88-
!/web_src/fomantic/build/themes/default
89-
/web_src/fomantic/build/themes/default/assets/*
90-
!/web_src/fomantic/build/themes/default/assets/fonts
91-
/web_src/fomantic/build/themes/default/assets/fonts/*
92-
!/web_src/fomantic/build/themes/default/assets/fonts/icons.woff2
93-
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
9482
/VERSION
9583
/.air
9684
/.go-licenses

.eslintrc.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module.exports = {
104104
'@vitest/no-disabled-tests': [0],
105105
'@vitest/no-done-callback': [0],
106106
'@vitest/no-duplicate-hooks': [0],
107-
'@vitest/no-focused-tests': [0],
107+
'@vitest/no-focused-tests': [2],
108108
'@vitest/no-hooks': [0],
109109
'@vitest/no-identical-title': [2],
110110
'@vitest/no-interpolation-in-snapshots': [0],
@@ -155,7 +155,7 @@ module.exports = {
155155
'eslint-plugin-vue-scoped-css',
156156
],
157157
extends: [
158-
'plugin:vue/vue3-recommended',
158+
'plugin:vue/recommended',
159159
'plugin:vue-scoped-css/vue3-recommended',
160160
],
161161
rules: {

.gitattributes

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
/public/assets/img/svg/*.svg linguist-generated
66
/templates/swagger/v1_json.tmpl linguist-generated
77
/vendor/** -text -eol linguist-vendored
8-
/web_src/fomantic/build/** linguist-generated
9-
/web_src/fomantic/_site/globals/site.variables linguist-language=Less
108
/web_src/js/vendor/** -text -eol linguist-vendored
119
Dockerfile.* linguist-language=Dockerfile

.gitignore

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,6 @@ cpu.out
8484
/public/assets/fonts
8585
/public/assets/licenses.txt
8686
/vendor
87-
/web_src/fomantic/node_modules
88-
/web_src/fomantic/build/*
89-
!/web_src/fomantic/build/semantic.js
90-
!/web_src/fomantic/build/semantic.css
91-
!/web_src/fomantic/build/themes
92-
/web_src/fomantic/build/themes/*
93-
!/web_src/fomantic/build/themes/default
94-
/web_src/fomantic/build/themes/default/assets/*
95-
!/web_src/fomantic/build/themes/default/assets/fonts
96-
/web_src/fomantic/build/themes/default/assets/fonts/*
97-
!/web_src/fomantic/build/themes/default/assets/fonts/icons.woff2
98-
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
9987
/VERSION
10088
/.air
10189
/.go-licenses

Makefile

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ 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.1.2
29+
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.2.1
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/[email protected].5
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/[email protected].7
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
@@ -115,8 +115,6 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
115115
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/))
116116
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
117117

118-
FOMANTIC_WORK_DIR := web_src/fomantic
119-
120118
WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
121119
WEBPACK_CONFIGS := webpack.config.js tailwind.config.js
122120
WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
@@ -140,7 +138,7 @@ TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
140138

141139
TEST_TAGS ?= $(TAGS_SPLIT) sqlite sqlite_unlock_notify
142140

143-
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)
141+
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)
144142

145143
GO_DIRS := build cmd models modules routers services tests
146144
WEB_DIRS := web_src/js web_src/css
@@ -847,19 +845,6 @@ update-py: node-check | node_modules ## update py dependencies
847845
poetry install
848846
@touch .venv
849847

850-
.PHONY: fomantic
851-
fomantic: ## build fomantic files
852-
rm -rf $(FOMANTIC_WORK_DIR)/build
853-
cd $(FOMANTIC_WORK_DIR) && npm install --no-save
854-
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
855-
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
856-
$(SED_INPLACE) -e 's/ overrideBrowserslist\r/ overrideBrowserslist: ["defaults"]\r/g' $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/tasks/config/tasks.js
857-
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
858-
# fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event
859-
$(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js
860-
$(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js
861-
rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*
862-
863848
.PHONY: webpack
864849
webpack: $(WEBPACK_DEST) ## build webpack files
865850

cmd/admin_auth_ldap.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,34 @@ var (
127127
&cli.UintFlag{
128128
Name: "page-size",
129129
Usage: "Search page size.",
130+
},
131+
&cli.BoolFlag{
132+
Name: "enable-groups",
133+
Usage: "Enable LDAP groups",
134+
},
135+
&cli.StringFlag{
136+
Name: "group-search-base-dn",
137+
Usage: "The LDAP base DN at which group accounts will be searched for",
138+
},
139+
&cli.StringFlag{
140+
Name: "group-member-attribute",
141+
Usage: "Group attribute containing list of users",
142+
},
143+
&cli.StringFlag{
144+
Name: "group-user-attribute",
145+
Usage: "User attribute listed in group",
146+
},
147+
&cli.StringFlag{
148+
Name: "group-filter",
149+
Usage: "Verify group membership in LDAP",
150+
},
151+
&cli.StringFlag{
152+
Name: "group-team-map",
153+
Usage: "Map LDAP groups to Organization teams",
154+
},
155+
&cli.BoolFlag{
156+
Name: "group-team-map-removal",
157+
Usage: "Remove users from synchronized teams if user does not belong to corresponding LDAP group",
130158
})
131159

132160
ldapSimpleAuthCLIFlags = append(commonLdapCLIFlags,
@@ -273,6 +301,27 @@ func parseLdapConfig(c *cli.Context, config *ldap.Source) error {
273301
if c.IsSet("skip-local-2fa") {
274302
config.SkipLocalTwoFA = c.Bool("skip-local-2fa")
275303
}
304+
if c.IsSet("enable-groups") {
305+
config.GroupsEnabled = c.Bool("enable-groups")
306+
}
307+
if c.IsSet("group-search-base-dn") {
308+
config.GroupDN = c.String("group-search-base-dn")
309+
}
310+
if c.IsSet("group-member-attribute") {
311+
config.GroupMemberUID = c.String("group-member-attribute")
312+
}
313+
if c.IsSet("group-user-attribute") {
314+
config.UserUID = c.String("group-user-attribute")
315+
}
316+
if c.IsSet("group-filter") {
317+
config.GroupFilter = c.String("group-filter")
318+
}
319+
if c.IsSet("group-team-map") {
320+
config.GroupTeamMap = c.String("group-team-map")
321+
}
322+
if c.IsSet("group-team-map-removal") {
323+
config.GroupTeamMapRemoval = c.Bool("group-team-map-removal")
324+
}
276325
return nil
277326
}
278327

cmd/admin_auth_ldap_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ func TestAddLdapBindDn(t *testing.T) {
5151
"--attributes-in-bind",
5252
"--synchronize-users",
5353
"--page-size", "99",
54+
"--enable-groups",
55+
"--group-search-base-dn", "ou=group,dc=full-domain-bind,dc=org",
56+
"--group-member-attribute", "memberUid",
57+
"--group-user-attribute", "uid",
58+
"--group-filter", "(|(cn=gitea_users)(cn=admins))",
59+
"--group-team-map", `{"cn=my-group,cn=groups,dc=example,dc=org": {"MyGiteaOrganization": ["MyGiteaTeam1", "MyGiteaTeam2"]}}`,
60+
"--group-team-map-removal",
5461
},
5562
source: &auth.Source{
5663
Type: auth.LDAP,
@@ -78,6 +85,13 @@ func TestAddLdapBindDn(t *testing.T) {
7885
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=full-domain-bind,dc=org)",
7986
RestrictedFilter: "(memberOf=cn=restricted-group,ou=example,dc=full-domain-bind,dc=org)",
8087
Enabled: true,
88+
GroupsEnabled: true,
89+
GroupDN: "ou=group,dc=full-domain-bind,dc=org",
90+
GroupMemberUID: "memberUid",
91+
UserUID: "uid",
92+
GroupFilter: "(|(cn=gitea_users)(cn=admins))",
93+
GroupTeamMap: `{"cn=my-group,cn=groups,dc=example,dc=org": {"MyGiteaOrganization": ["MyGiteaTeam1", "MyGiteaTeam2"]}}`,
94+
GroupTeamMapRemoval: true,
8195
},
8296
},
8397
},
@@ -510,6 +524,13 @@ func TestUpdateLdapBindDn(t *testing.T) {
510524
"--bind-password", "secret-bind-full",
511525
"--synchronize-users",
512526
"--page-size", "99",
527+
"--enable-groups",
528+
"--group-search-base-dn", "ou=group,dc=full-domain-bind,dc=org",
529+
"--group-member-attribute", "memberUid",
530+
"--group-user-attribute", "uid",
531+
"--group-filter", "(|(cn=gitea_users)(cn=admins))",
532+
"--group-team-map", `{"cn=my-group,cn=groups,dc=example,dc=org": {"MyGiteaOrganization": ["MyGiteaTeam1", "MyGiteaTeam2"]}}`,
533+
"--group-team-map-removal",
513534
},
514535
id: 23,
515536
existingAuthSource: &auth.Source{
@@ -545,6 +566,13 @@ func TestUpdateLdapBindDn(t *testing.T) {
545566
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=full-domain-bind,dc=org)",
546567
RestrictedFilter: "(memberOf=cn=restricted-group,ou=example,dc=full-domain-bind,dc=org)",
547568
Enabled: true,
569+
GroupsEnabled: true,
570+
GroupDN: "ou=group,dc=full-domain-bind,dc=org",
571+
GroupMemberUID: "memberUid",
572+
UserUID: "uid",
573+
GroupFilter: "(|(cn=gitea_users)(cn=admins))",
574+
GroupTeamMap: `{"cn=my-group,cn=groups,dc=example,dc=org": {"MyGiteaOrganization": ["MyGiteaTeam1", "MyGiteaTeam2"]}}`,
575+
GroupTeamMapRemoval: true,
548576
},
549577
},
550578
},

models/actions/run.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err
194194

195195
// CancelPreviousJobs cancels all previous jobs of the same repository, reference, workflow, and event.
196196
// It's useful when a new run is triggered, and all previous runs needn't be continued anymore.
197-
func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID string, event webhook_module.HookEventType) error {
197+
func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID string, event webhook_module.HookEventType) ([]*ActionRunJob, error) {
198198
// Find all runs in the specified repository, reference, and workflow with non-final status
199199
runs, total, err := db.FindAndCount[ActionRun](ctx, FindRunOptions{
200200
RepoID: repoID,
@@ -204,22 +204,24 @@ func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID strin
204204
Status: []Status{StatusRunning, StatusWaiting, StatusBlocked},
205205
})
206206
if err != nil {
207-
return err
207+
return nil, err
208208
}
209209

210210
// If there are no runs found, there's no need to proceed with cancellation, so return nil.
211211
if total == 0 {
212-
return nil
212+
return nil, nil
213213
}
214214

215+
cancelledJobs := make([]*ActionRunJob, 0, total)
216+
215217
// Iterate over each found run and cancel its associated jobs.
216218
for _, run := range runs {
217219
// Find all jobs associated with the current run.
218220
jobs, err := db.Find[ActionRunJob](ctx, FindRunJobOptions{
219221
RunID: run.ID,
220222
})
221223
if err != nil {
222-
return err
224+
return cancelledJobs, err
223225
}
224226

225227
// Iterate over each job and attempt to cancel it.
@@ -238,27 +240,29 @@ func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID strin
238240
// Update the job's status and stopped time in the database.
239241
n, err := UpdateRunJob(ctx, job, builder.Eq{"task_id": 0}, "status", "stopped")
240242
if err != nil {
241-
return err
243+
return cancelledJobs, err
242244
}
243245

244246
// If the update affected 0 rows, it means the job has changed in the meantime, so we need to try again.
245247
if n == 0 {
246-
return fmt.Errorf("job has changed, try again")
248+
return cancelledJobs, fmt.Errorf("job has changed, try again")
247249
}
248250

251+
cancelledJobs = append(cancelledJobs, job)
249252
// Continue with the next job.
250253
continue
251254
}
252255

253256
// If the job has an associated task, try to stop the task, effectively cancelling the job.
254257
if err := StopTask(ctx, job.TaskID, StatusCancelled); err != nil {
255-
return err
258+
return cancelledJobs, err
256259
}
260+
cancelledJobs = append(cancelledJobs, job)
257261
}
258262
}
259263

260264
// Return nil to indicate successful cancellation of all running and waiting jobs.
261-
return nil
265+
return cancelledJobs, nil
262266
}
263267

264268
// InsertRun inserts a run

models/actions/runner.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ type ActionRunner struct {
5757

5858
// Store labels defined in state file (default: .runner file) of `act_runner`
5959
AgentLabels []string `xorm:"TEXT"`
60+
// Store if this is a runner that only ever get one single job assigned
61+
Ephemeral bool `xorm:"ephemeral NOT NULL DEFAULT false"`
6062

6163
Created timeutil.TimeStamp `xorm:"created"`
6264
Updated timeutil.TimeStamp `xorm:"updated"`

0 commit comments

Comments
 (0)