Skip to content

Commit 62e84f3

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix various Fomantic UI and htmx problems (go-gitea#33851) Add workflow_job webhook (go-gitea#33694) Fix file icon mapping (go-gitea#33855) Drop fomantic build (go-gitea#33845) Fix auto concurrency cancellation skips commit status updates (go-gitea#33764) Fix test code (go-gitea#33829) Remove "noscript" tag from html head (go-gitea#33846) Fix material icon & diff highlight (go-gitea#33844) Fix LFS URL (go-gitea#33840) Add material icons for file list (go-gitea#33837)
2 parents 7aa16d2 + 91610a9 commit 62e84f3

File tree

120 files changed

+25357
-25687
lines changed

Some content is hidden

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

120 files changed

+25357
-25687
lines changed

.dockerignore

-12
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

.gitattributes

-2
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

-12
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

+1-16
Original file line numberDiff line numberDiff line change
@@ -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

custom/conf/app.example.ini

+3
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,9 @@ LEVEL = Info
12941294
;; Leave it empty to allow users to select any theme from "{CustomPath}/public/assets/css/theme-*.css"
12951295
;THEMES =
12961296
;;
1297+
;; The icons for file list (basic/material), this is a temporary option which will be replaced by a user setting in the future.
1298+
;FILE_ICON_THEME = material
1299+
;;
12971300
;; All available reactions users can choose on issues/prs and comments.
12981301
;; Values can be emoji alias (:smile:) or a unicode emoji.
12991302
;; For custom reactions, add a tightly cropped square image to public/assets/img/emoji/reaction_name.png

models/actions/run.go

+12-8
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/schedule.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,22 @@ func DeleteScheduleTaskByRepo(ctx context.Context, id int64) error {
117117
return committer.Commit()
118118
}
119119

120-
func CleanRepoScheduleTasks(ctx context.Context, repo *repo_model.Repository) error {
120+
func CleanRepoScheduleTasks(ctx context.Context, repo *repo_model.Repository) ([]*ActionRunJob, error) {
121121
// If actions disabled when there is schedule task, this will remove the outdated schedule tasks
122122
// There is no other place we can do this because the app.ini will be changed manually
123123
if err := DeleteScheduleTaskByRepo(ctx, repo.ID); err != nil {
124-
return fmt.Errorf("DeleteCronTaskByRepo: %v", err)
124+
return nil, fmt.Errorf("DeleteCronTaskByRepo: %v", err)
125125
}
126126
// cancel running cron jobs of this repository and delete old schedules
127-
if err := CancelPreviousJobs(
127+
jobs, err := CancelPreviousJobs(
128128
ctx,
129129
repo.ID,
130130
repo.DefaultBranch,
131131
"",
132132
webhook_module.HookEventSchedule,
133-
); err != nil {
134-
return fmt.Errorf("CancelPreviousJobs: %v", err)
133+
)
134+
if err != nil {
135+
return jobs, fmt.Errorf("CancelPreviousJobs: %v", err)
135136
}
136-
return nil
137+
return jobs, nil
137138
}

models/webhook/webhook_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func TestWebhook_EventsArray(t *testing.T) {
7373
"pull_request", "pull_request_assign", "pull_request_label", "pull_request_milestone",
7474
"pull_request_comment", "pull_request_review_approved", "pull_request_review_rejected",
7575
"pull_request_review_comment", "pull_request_sync", "pull_request_review_request", "wiki", "repository", "release",
76-
"package", "status",
76+
"package", "status", "workflow_job",
7777
},
7878
(&Webhook{
7979
HookEvent: &webhook_module.HookEvent{SendEverything: true},

modules/base/tool.go

-22
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"strings"
1818
"time"
1919

20-
"code.gitea.io/gitea/modules/git"
2120
"code.gitea.io/gitea/modules/setting"
2221
"code.gitea.io/gitea/modules/util"
2322

@@ -139,24 +138,3 @@ func Int64sToStrings(ints []int64) []string {
139138
}
140139
return strs
141140
}
142-
143-
// EntryIcon returns the octicon name for displaying files/directories
144-
func EntryIcon(entry *git.TreeEntry) string {
145-
switch {
146-
case entry.IsLink():
147-
te, err := entry.FollowLink()
148-
if err != nil {
149-
return "file-symlink-file"
150-
}
151-
if te.IsDir() {
152-
return "file-directory-symlink"
153-
}
154-
return "file-symlink-file"
155-
case entry.IsDir():
156-
return "file-directory-fill"
157-
case entry.IsSubModule():
158-
return "file-submodule"
159-
}
160-
161-
return "file"
162-
}

modules/fileicon/basic.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package fileicon
5+
6+
import (
7+
"html/template"
8+
9+
"code.gitea.io/gitea/modules/git"
10+
"code.gitea.io/gitea/modules/svg"
11+
)
12+
13+
func BasicThemeIcon(entry *git.TreeEntry) template.HTML {
14+
svgName := "octicon-file"
15+
switch {
16+
case entry.IsLink():
17+
svgName = "octicon-file-symlink-file"
18+
if te, err := entry.FollowLink(); err == nil && te.IsDir() {
19+
svgName = "octicon-file-directory-symlink"
20+
}
21+
case entry.IsDir():
22+
svgName = "octicon-file-directory-fill"
23+
case entry.IsSubModule():
24+
svgName = "octicon-file-submodule"
25+
}
26+
return svg.RenderHTML(svgName)
27+
}

0 commit comments

Comments
 (0)