Skip to content

Commit 6399e84

Browse files
committed
Merge remote-tracking branch 'origin/main' into fixmerge
* origin/main: Move Fomantic dropdown CSS to custom module (go-gitea#36530) Use "Enable Gravatar" but not "Disable" (go-gitea#36771) feat: add branch_count to repository API (go-gitea#35351) (go-gitea#36743) Deprecate RenderWithErr (go-gitea#36769) Lazy-load some Vue components, fix heatmap chunk loading on every page (go-gitea#36719) Filter out untracked files from spellchecking (go-gitea#36756) Fix CSS stacking context issue in actions log (go-gitea#36749) Fix milestone/project text overflow in issue sidebar (go-gitea#36741) Update tool dependencies and fix new lint issues (go-gitea#36702) Instance-wide (global) info banner and maintenance mode (go-gitea#36571) Add created_by filter to SearchIssues (go-gitea#36670) Inline and lazy-load EasyMDE CSS, fix border colors (go-gitea#36714) # Conflicts: # templates/repo/issue/view_content/pull_merge_box.tmpl # web_src/js/features/repo-issue-pull.ts
2 parents f7dcbd8 + 50ec48d commit 6399e84

116 files changed

Lines changed: 2780 additions & 2688 deletions

File tree

Some content is hidden

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

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ linters:
141141
- linters:
142142
- unused
143143
text: (?i)swagger
144-
- linters:
145-
- staticcheck
146-
text: (?i)argument x is overwritten before first use
147144
- linters:
148145
- gocritic
149146
text: '(?i)commentFormatting: put a space between `//` and comment text'

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ XGO_VERSION := go-1.25.x
1515
AIR_PACKAGE ?= github.com/air-verse/air@v1
1616
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
1717
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.9.2
18-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0
18+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.10.1
1919
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.15
20-
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.7.0
20+
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.8.0
2121
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1
2222
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
2323
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
24-
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.7.10
24+
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.7.11
2525

2626
DOCKER_IMAGE ?= gitea/gitea
2727
DOCKER_TAG ?= latest
@@ -322,11 +322,11 @@ lint-md-fix: node_modules ## lint markdown files and fix issues
322322

323323
.PHONY: lint-spell
324324
lint-spell: ## lint spelling
325-
@go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -error $(SPELLCHECK_FILES)
325+
@git ls-files $(SPELLCHECK_FILES) | xargs go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -error
326326

327327
.PHONY: lint-spell-fix
328328
lint-spell-fix: ## lint spelling and fix issues
329-
@go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -w $(SPELLCHECK_FILES)
329+
@git ls-files $(SPELLCHECK_FILES) | xargs go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -w
330330

331331
.PHONY: lint-go
332332
lint-go: ## lint go files

custom/conf/app.example.ini

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,6 @@ RUN_USER = ; git
238238
;; Indicate whether to check minimum key size with corresponding type
239239
;MINIMUM_KEY_SIZE_CHECK = false
240240
;;
241-
;; Disable CDN even in "prod" mode
242-
;OFFLINE_MODE = true
243-
;;
244241
;; TLS Settings: Either ACME or manual
245242
;; (Other common TLS configuration are found before)
246243
;ENABLE_ACME = false
@@ -1983,12 +1980,12 @@ LEVEL = Info
19831980
;; or a custom avatar source, like: http://cn.gravatar.com/avatar/
19841981
;GRAVATAR_SOURCE = gravatar
19851982
;;
1986-
;; This value will always be true in offline mode.
1983+
;; Deprecated, see Web UI Admin Panel -> Config -> Settings
19871984
;DISABLE_GRAVATAR = false
19881985
;;
19891986
;; Federated avatar lookup uses DNS to discover avatar associated
19901987
;; with emails, see https://www.libravatar.org
1991-
;; This value will always be false in offline mode or when Gravatar is disabled.
1988+
;; Deprecated, see Web UI Admin Panel -> Config -> Settings
19921989
;ENABLE_FEDERATED_AVATAR = false
19931990

19941991
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

models/git/branch.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,3 +583,12 @@ func FindRecentlyPushedNewBranches(ctx context.Context, doer *user_model.User, o
583583

584584
return newBranches, nil
585585
}
586+
587+
// CountBranches returns the number of branches in the repository
588+
func CountBranches(ctx context.Context, repoID int64, includeDeleted bool) (int64, error) {
589+
sess := db.GetEngine(ctx).Where("repo_id=?", repoID)
590+
if !includeDeleted {
591+
sess.And("is_deleted=?", false)
592+
}
593+
return sess.Count(new(Branch))
594+
}

models/git/branch_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,25 @@ func TestOnlyGetDeletedBranchOnCorrectRepo(t *testing.T) {
263263
assert.NoError(t, err)
264264
assert.NotNil(t, deletedBranch)
265265
}
266+
267+
func TestCountBranches(t *testing.T) {
268+
// 1. Setup - Exactly like TestAddDeletedBranch
269+
assert.NoError(t, unittest.PrepareTestDatabase())
270+
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
271+
272+
// 2. Execution - Using t.Context() to match the rest of the file
273+
initialCount, err := git_model.CountBranches(t.Context(), repo.ID, false)
274+
assert.NoError(t, err)
275+
276+
// 3. Database Action - Using t.Context()
277+
err = db.Insert(t.Context(), &git_model.Branch{
278+
RepoID: repo.ID,
279+
Name: "test-branch-for-counting",
280+
})
281+
assert.NoError(t, err)
282+
283+
// 4. Verification
284+
newCount, err := git_model.CountBranches(t.Context(), repo.ID, false)
285+
assert.NoError(t, err)
286+
assert.Equal(t, initialCount+1, newCount)
287+
}

models/repo/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func (repo *Repository) SizeDetailsString() string {
281281
var str strings.Builder
282282
sizeDetails := repo.SizeDetails()
283283
for _, detail := range sizeDetails {
284-
str.WriteString(fmt.Sprintf("%s: %s, ", detail.Name, base.FileSize(detail.Size)))
284+
fmt.Fprintf(&str, "%s: %s, ", detail.Name, base.FileSize(detail.Size))
285285
}
286286
return strings.TrimSuffix(str.String(), ", ")
287287
}

models/user/avatar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (u *User) AvatarLinkWithSize(ctx context.Context, size int) string {
7474
switch {
7575
case u.UseCustomAvatar:
7676
useLocalAvatar = true
77-
case disableGravatar, setting.OfflineMode:
77+
case disableGravatar:
7878
useLocalAvatar = true
7979
autoGenerateAvatar = true
8080
}

modules/git/foreachref/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (f Format) Flag() string {
5353
var formatFlag strings.Builder
5454
for i, field := range f.fieldNames {
5555
// field key and field value
56-
formatFlag.WriteString(fmt.Sprintf("%s %%(%s)", field, field))
56+
fmt.Fprintf(&formatFlag, "%s %%(%s)", field, field)
5757

5858
if i < len(f.fieldNames)-1 {
5959
// note: escape delimiters to allow control characters as

modules/markup/sanitizer_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (st *Sanitizer) createDefaultPolicy() *bluemonday.Policy {
8181
"data-markdown-generated-content", "data-attr-class",
8282
}
8383
generalSafeElements := []string{
84-
"h1", "h2", "h3", "h4", "h5", "h6", "h7", "h8", "br", "b", "i", "strong", "em", "a", "pre", "code", "img", "tt",
84+
"h1", "h2", "h3", "h4", "h5", "h6", "h7", "h8", "br", "b", "center", "i", "strong", "em", "a", "pre", "code", "img", "tt",
8585
"div", "ins", "del", "sup", "sub", "p", "ol", "ul", "table", "thead", "tbody", "tfoot", "blockquote", "label",
8686
"dl", "dt", "dd", "kbd", "q", "samp", "var", "hr", "ruby", "rt", "rp", "li", "tr", "td", "th", "s", "strike", "summary",
8787
"details", "caption", "figure", "figcaption",

modules/setting/config.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
)
1313

1414
type PictureStruct struct {
15-
DisableGravatar *config.Value[bool]
16-
EnableFederatedAvatar *config.Value[bool]
15+
DisableGravatar *config.Option[bool]
16+
EnableFederatedAvatar *config.Option[bool]
1717
}
1818

1919
type OpenWithEditorApp struct {
@@ -23,6 +23,9 @@ type OpenWithEditorApp struct {
2323

2424
type OpenWithEditorAppsType []OpenWithEditorApp
2525

26+
// ToTextareaString is only used in templates, for help prompt only
27+
// TODO: OPEN-WITH-EDITOR-APP-JSON: Because there is no "rich UI", a plain text editor is used to manage the list of apps
28+
// Maybe we can use some better formats like Yaml in the future, then a simple textarea can manage the config clearly
2629
func (t OpenWithEditorAppsType) ToTextareaString() string {
2730
var ret strings.Builder
2831
for _, app := range t {
@@ -31,7 +34,7 @@ func (t OpenWithEditorAppsType) ToTextareaString() string {
3134
return ret.String()
3235
}
3336

34-
func DefaultOpenWithEditorApps() OpenWithEditorAppsType {
37+
func openWithEditorAppsDefaultValue() OpenWithEditorAppsType {
3538
return OpenWithEditorAppsType{
3639
{
3740
DisplayName: "VS Code",
@@ -49,13 +52,14 @@ func DefaultOpenWithEditorApps() OpenWithEditorAppsType {
4952
}
5053

5154
type RepositoryStruct struct {
52-
OpenWithEditorApps *config.Value[OpenWithEditorAppsType]
53-
GitGuideRemoteName *config.Value[string]
55+
OpenWithEditorApps *config.Option[OpenWithEditorAppsType]
56+
GitGuideRemoteName *config.Option[string]
5457
}
5558

5659
type ConfigStruct struct {
5760
Picture *PictureStruct
5861
Repository *RepositoryStruct
62+
Instance *InstanceStruct
5963
}
6064

6165
var (
@@ -67,12 +71,16 @@ func initDefaultConfig() {
6771
config.SetCfgSecKeyGetter(&cfgSecKeyGetter{})
6872
defaultConfig = &ConfigStruct{
6973
Picture: &PictureStruct{
70-
DisableGravatar: config.ValueJSON[bool]("picture.disable_gravatar").WithFileConfig(config.CfgSecKey{Sec: "picture", Key: "DISABLE_GRAVATAR"}),
71-
EnableFederatedAvatar: config.ValueJSON[bool]("picture.enable_federated_avatar").WithFileConfig(config.CfgSecKey{Sec: "picture", Key: "ENABLE_FEDERATED_AVATAR"}),
74+
DisableGravatar: config.NewOption[bool]("picture.disable_gravatar").WithDefaultSimple(true).WithFileConfig(config.CfgSecKey{Sec: "picture", Key: "DISABLE_GRAVATAR"}),
75+
EnableFederatedAvatar: config.NewOption[bool]("picture.enable_federated_avatar").WithFileConfig(config.CfgSecKey{Sec: "picture", Key: "ENABLE_FEDERATED_AVATAR"}),
7276
},
7377
Repository: &RepositoryStruct{
74-
OpenWithEditorApps: config.ValueJSON[OpenWithEditorAppsType]("repository.open-with.editor-apps"),
75-
GitGuideRemoteName: config.ValueJSON[string]("repository.git-guide-remote-name").WithDefault("origin"),
78+
OpenWithEditorApps: config.NewOption[OpenWithEditorAppsType]("repository.open-with.editor-apps").WithEmptyAsDefault().WithDefaultFunc(openWithEditorAppsDefaultValue),
79+
GitGuideRemoteName: config.NewOption[string]("repository.git-guide-remote-name").WithEmptyAsDefault().WithDefaultSimple("origin"),
80+
},
81+
Instance: &InstanceStruct{
82+
WebBanner: config.NewOption[WebBannerType]("instance.web_banner"),
83+
MaintenanceMode: config.NewOption[MaintenanceModeType]("instance.maintenance_mode"),
7684
},
7785
}
7886
}

0 commit comments

Comments
 (0)