Skip to content

Commit c0c7beb

Browse files
authored
Merge branch 'main' into fix-actions-schedule-update
2 parents 01e3c6a + 39c08ce commit c0c7beb

File tree

65 files changed

+767
-335
lines changed

Some content is hidden

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

65 files changed

+767
-335
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ TEST_TAGS ?= $(TAGS_SPLIT) sqlite sqlite_unlock_notify
163163

164164
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)
165165

166-
GO_DIRS := build cmd models modules routers services tests
166+
GO_DIRS := build cmd models modules routers services tests tools
167167
WEB_DIRS := web_src/js web_src/css
168168

169169
ESLINT_FILES := web_src/js tools *.ts tests/e2e
170170
STYLELINT_FILES := web_src/css web_src/js/components/*.vue
171-
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) templates options/locale/locale_en-US.ini .github $(filter-out CHANGELOG.md, $(wildcard *.go *.md *.yml *.yaml *.toml)) $(filter-out tools/misspellings.csv, $(wildcard tools/*))
171+
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) templates options/locale/locale_en-US.ini .github $(filter-out CHANGELOG.md, $(wildcard *.go *.md *.yml *.yaml *.toml))
172172
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
173173

174174
GO_SOURCES := $(wildcard *.go)
@@ -376,11 +376,11 @@ lint-md: node_modules ## lint markdown files
376376

377377
.PHONY: lint-spell
378378
lint-spell: ## lint spelling
379-
@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -error $(SPELLCHECK_FILES)
379+
@go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -error $(SPELLCHECK_FILES)
380380

381381
.PHONY: lint-spell-fix
382382
lint-spell-fix: ## lint spelling and fix issues
383-
@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -w $(SPELLCHECK_FILES)
383+
@go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -w $(SPELLCHECK_FILES)
384384

385385
.PHONY: lint-go
386386
lint-go: ## lint go files
File renamed without changes.

eslint.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ export default defineConfig([
774774
'unicorn/no-empty-file': [2],
775775
'unicorn/no-for-loop': [0],
776776
'unicorn/no-hex-escape': [0],
777+
'unicorn/no-immediate-mutation': [0],
777778
'unicorn/no-instanceof-array': [0],
778779
'unicorn/no-invalid-fetch-options': [2],
779780
'unicorn/no-invalid-remove-event-listener': [2],
@@ -799,6 +800,7 @@ export default defineConfig([
799800
'unicorn/no-unreadable-array-destructuring': [0],
800801
'unicorn/no-unreadable-iife': [2],
801802
'unicorn/no-unused-properties': [2],
803+
'unicorn/no-useless-collection-argument': [2],
802804
'unicorn/no-useless-fallback-in-spread': [2],
803805
'unicorn/no-useless-length-check': [2],
804806
'unicorn/no-useless-promise-resolve-reject': [2],
@@ -810,8 +812,8 @@ export default defineConfig([
810812
'unicorn/numeric-separators-style': [0],
811813
'unicorn/prefer-add-event-listener': [2],
812814
'unicorn/prefer-array-find': [2],
813-
'unicorn/prefer-array-flat-map': [2],
814815
'unicorn/prefer-array-flat': [2],
816+
'unicorn/prefer-array-flat-map': [2],
815817
'unicorn/prefer-array-index-of': [2],
816818
'unicorn/prefer-array-some': [2],
817819
'unicorn/prefer-at': [0],
@@ -846,6 +848,7 @@ export default defineConfig([
846848
'unicorn/prefer-query-selector': [2],
847849
'unicorn/prefer-reflect-apply': [0],
848850
'unicorn/prefer-regexp-test': [2],
851+
'unicorn/prefer-response-static-json': [2],
849852
'unicorn/prefer-set-has': [0],
850853
'unicorn/prefer-set-size': [2],
851854
'unicorn/prefer-spread': [0],
@@ -921,6 +924,7 @@ export default defineConfig([
921924
'vue/html-closing-bracket-spacing': [2, {startTag: 'never', endTag: 'never', selfClosingTag: 'never'}],
922925
'vue/max-attributes-per-line': [0],
923926
'vue/singleline-html-element-content-newline': [0],
927+
'vue/require-typed-ref': [2],
924928
},
925929
},
926930
{

models/perm/access/repo_permission.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ func GetActionsUserRepoPermission(ctx context.Context, repo *repo_model.Reposito
276276
// The task repo can access the current repo only if the task repo is private and
277277
// the owner of the task repo is a collaborative owner of the current repo.
278278
// FIXME allow public repo read access if tokenless pull is enabled
279+
// FIXME should owner's visibility also be considered here?
279280
return perm, nil
280281
}
281282
accessMode = perm_model.AccessModeRead

modules/setting/session.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"code.gitea.io/gitea/modules/json"
1212
"code.gitea.io/gitea/modules/log"
13+
"code.gitea.io/gitea/modules/util"
1314
)
1415

1516
// SessionConfig defines Session settings
@@ -49,10 +50,8 @@ func loadSessionFrom(rootCfg ConfigProvider) {
4950
checkOverlappedPath("[session].PROVIDER_CONFIG", SessionConfig.ProviderConfig)
5051
}
5152
SessionConfig.CookieName = sec.Key("COOKIE_NAME").MustString("i_like_gitea")
52-
SessionConfig.CookiePath = AppSubURL
53-
if SessionConfig.CookiePath == "" {
54-
SessionConfig.CookiePath = "/"
55-
}
53+
// HINT: INSTALL-PAGE-COOKIE-INIT: the cookie system is not properly initialized on the Install page, so there is no CookiePath
54+
SessionConfig.CookiePath = util.IfZero(AppSubURL, "/")
5655
SessionConfig.Secure = sec.Key("COOKIE_SECURE").MustBool(strings.HasPrefix(strings.ToLower(AppURL), "https://"))
5756
SessionConfig.Gclifetime = sec.Key("GC_INTERVAL_TIME").MustInt64(86400)
5857
SessionConfig.Maxlifetime = sec.Key("SESSION_LIFE_TIME").MustInt64(86400)

modules/svg/svg.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func MockIcon(icon string) func() {
5858

5959
// RenderHTML renders icons - arguments icon name (string), size (int), class (string)
6060
func RenderHTML(icon string, others ...any) template.HTML {
61+
if icon == "" {
62+
return ""
63+
}
6164
size, class := gitea_html.ParseSizeAndClass(defaultSize, "", others...)
6265
if svgStr, ok := svgIcons[icon]; ok {
6366
// the code is somewhat hacky, but it just works, because the SVG contents are all normalized

modules/templates/helper.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"strings"
1313
"time"
1414

15-
user_model "code.gitea.io/gitea/models/user"
1615
"code.gitea.io/gitea/modules/base"
1716
"code.gitea.io/gitea/modules/htmlutil"
1817
"code.gitea.io/gitea/modules/markup"
@@ -21,7 +20,6 @@ import (
2120
"code.gitea.io/gitea/modules/templates/eval"
2221
"code.gitea.io/gitea/modules/util"
2322
"code.gitea.io/gitea/services/gitdiff"
24-
"code.gitea.io/gitea/services/webtheme"
2523
)
2624

2725
// NewFuncMap returns functions for injecting to templates
@@ -130,7 +128,6 @@ func NewFuncMap() template.FuncMap {
130128
"DisableWebhooks": func() bool {
131129
return setting.DisableWebhooks
132130
},
133-
"UserThemeName": userThemeName,
134131
"NotificationSettings": func() map[string]any {
135132
return map[string]any{
136133
"MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond),
@@ -217,16 +214,6 @@ func evalTokens(tokens ...any) (any, error) {
217214
return n.Value, err
218215
}
219216

220-
func userThemeName(user *user_model.User) string {
221-
if user == nil || user.Theme == "" {
222-
return setting.UI.DefaultTheme
223-
}
224-
if webtheme.IsThemeAvailable(user.Theme) {
225-
return user.Theme
226-
}
227-
return setting.UI.DefaultTheme
228-
}
229-
230217
func isQueryParamEmpty(v any) bool {
231218
return v == nil || v == false || v == 0 || v == int64(0) || v == ""
232219
}

modules/templates/util_render.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ import (
2323
"code.gitea.io/gitea/modules/markup/markdown"
2424
"code.gitea.io/gitea/modules/reqctx"
2525
"code.gitea.io/gitea/modules/setting"
26+
"code.gitea.io/gitea/modules/svg"
2627
"code.gitea.io/gitea/modules/translation"
2728
"code.gitea.io/gitea/modules/util"
29+
"code.gitea.io/gitea/services/webtheme"
2830
)
2931

3032
type RenderUtils struct {
@@ -259,3 +261,18 @@ func (ut *RenderUtils) RenderLabels(labels []*issues_model.Label, repoLink strin
259261
htmlCode += "</span>"
260262
return template.HTML(htmlCode)
261263
}
264+
265+
func (ut *RenderUtils) RenderThemeItem(info *webtheme.ThemeMetaInfo, iconSize int) template.HTML {
266+
svgName := "octicon-paintbrush"
267+
switch info.ColorScheme {
268+
case "dark":
269+
svgName = "octicon-moon"
270+
case "light":
271+
svgName = "octicon-sun"
272+
case "auto":
273+
svgName = "gitea-eclipse"
274+
}
275+
icon := svg.RenderHTML(svgName, iconSize)
276+
extraIcon := svg.RenderHTML(info.GetExtraIconName(), iconSize)
277+
return htmlutil.HTMLFormat(`<div class="theme-menu-item" data-tooltip-content="%s">%s %s %s</div>`, info.GetDescription(), icon, info.DisplayName, extraIcon)
278+
}

modules/web/middleware/cookie.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"code.gitea.io/gitea/modules/session"
1313
"code.gitea.io/gitea/modules/setting"
14+
"code.gitea.io/gitea/modules/util"
1415
)
1516

1617
// SetRedirectToCookie convenience function to set the RedirectTo cookie consistently
@@ -39,11 +40,13 @@ func SetSiteCookie(resp http.ResponseWriter, name, value string, maxAge int) {
3940
// These are more specific than cookies without a trailing /, so
4041
// we need to delete these if they exist.
4142
deleteLegacySiteCookie(resp, name)
43+
44+
// HINT: INSTALL-PAGE-COOKIE-INIT: the cookie system is not properly initialized on the Install page, so there is no CookiePath
4245
cookie := &http.Cookie{
4346
Name: name,
4447
Value: url.QueryEscape(value),
4548
MaxAge: maxAge,
46-
Path: setting.SessionConfig.CookiePath,
49+
Path: util.IfZero(setting.SessionConfig.CookiePath, "/"),
4750
Domain: setting.SessionConfig.Domain,
4851
Secure: setting.SessionConfig.Secure,
4952
HttpOnly: true,

modules/web/middleware/data.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func GetContextData(c context.Context) reqctx.ContextData {
2222

2323
func CommonTemplateContextData() reqctx.ContextData {
2424
return reqctx.ContextData{
25+
"PageTitleCommon": setting.AppName,
26+
2527
"IsLandingPageOrganizations": setting.LandingPageURL == setting.LandingPageOrganizations,
2628

2729
"ShowRegistrationButton": setting.Service.ShowRegistrationButton,

0 commit comments

Comments
 (0)