Skip to content

Commit af2cc30

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Fix migrate input box bug (go-gitea#35166) [skip ci] Updated translations via Crowdin Only hide dropzone when no files have been uploaded (go-gitea#35156) Change some columns from text to longtext and fix column wrong type caused by xorm (go-gitea#35141) [skip ci] Updated translations via Crowdin Add `owner` and `parent` fields clarification to docs (go-gitea#35023) Improve language in en-US locale strings (go-gitea#35124)
2 parents 2e8e0d0 + 1b4d080 commit af2cc30

Some content is hidden

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

48 files changed

+455
-2909
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ require (
131131
mvdan.cc/xurls/v2 v2.6.0
132132
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
133133
xorm.io/builder v0.3.13
134-
xorm.io/xorm v1.3.9
134+
xorm.io/xorm v1.3.10
135135
)
136136

137137
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,5 +955,5 @@ strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 h1:mUcz5b3
955955
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:FJGmPh3vz9jSos1L/F91iAgnC/aejc0wIIrF2ZwJxdY=
956956
xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo=
957957
xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
958-
xorm.io/xorm v1.3.9 h1:TUovzS0ko+IQ1XnNLfs5dqK1cJl1H5uHpWbWqAQ04nU=
959-
xorm.io/xorm v1.3.9/go.mod h1:LsCCffeeYp63ssk0pKumP6l96WZcHix7ChpurcLNuMw=
958+
xorm.io/xorm v1.3.10 h1:yR83hTT4mKIPyA/lvWFTzS35xjLwkiYnwdw0Qupeh0o=
959+
xorm.io/xorm v1.3.10/go.mod h1:Lo7hmsFF0F0GbDE7ubX5ZKa+eCf0eCuiJAUG3oI5cxQ=

models/migrations/migrations.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"code.gitea.io/gitea/models/migrations/v1_22"
2525
"code.gitea.io/gitea/models/migrations/v1_23"
2626
"code.gitea.io/gitea/models/migrations/v1_24"
27+
"code.gitea.io/gitea/models/migrations/v1_25"
2728
"code.gitea.io/gitea/models/migrations/v1_6"
2829
"code.gitea.io/gitea/models/migrations/v1_7"
2930
"code.gitea.io/gitea/models/migrations/v1_8"
@@ -382,6 +383,9 @@ func prepareMigrationTasks() []*migration {
382383
newMigration(318, "Add anonymous_access_mode for repo_unit", v1_24.AddRepoUnitAnonymousAccessMode),
383384
newMigration(319, "Add ExclusiveOrder to Label table", v1_24.AddExclusiveOrderColumnToLabelTable),
384385
newMigration(320, "Migrate two_factor_policy to login_source table", v1_24.MigrateSkipTwoFactor),
386+
387+
// Gitea 1.24.0 ends at database version 321
388+
newMigration(321, "Use LONGTEXT for some columns and fix review_state.updated_files column", v1_25.UseLongTextInSomeColumnsAndFixBugs),
385389
}
386390
return preparedMigrations
387391
}

models/migrations/v1_25/main_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_25
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/models/migrations/base"
10+
)
11+
12+
func TestMain(m *testing.M) {
13+
base.MainTest(m)
14+
}

models/migrations/v1_25/v321.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_25
5+
6+
import (
7+
"code.gitea.io/gitea/models/migrations/base"
8+
"code.gitea.io/gitea/modules/setting"
9+
10+
"xorm.io/xorm"
11+
"xorm.io/xorm/schemas"
12+
)
13+
14+
func UseLongTextInSomeColumnsAndFixBugs(x *xorm.Engine) error {
15+
if !setting.Database.Type.IsMySQL() {
16+
return nil // Only mysql need to change from text to long text, for other databases, they are the same
17+
}
18+
19+
if err := base.ModifyColumn(x, "review_state", &schemas.Column{
20+
Name: "updated_files",
21+
SQLType: schemas.SQLType{
22+
Name: "LONGTEXT",
23+
},
24+
Length: 0,
25+
Nullable: false,
26+
DefaultIsEmpty: true,
27+
}); err != nil {
28+
return err
29+
}
30+
31+
if err := base.ModifyColumn(x, "package_property", &schemas.Column{
32+
Name: "value",
33+
SQLType: schemas.SQLType{
34+
Name: "LONGTEXT",
35+
},
36+
Length: 0,
37+
Nullable: false,
38+
DefaultIsEmpty: true,
39+
}); err != nil {
40+
return err
41+
}
42+
43+
return base.ModifyColumn(x, "notice", &schemas.Column{
44+
Name: "description",
45+
SQLType: schemas.SQLType{
46+
Name: "LONGTEXT",
47+
},
48+
Length: 0,
49+
Nullable: false,
50+
DefaultIsEmpty: true,
51+
})
52+
}

models/migrations/v1_25/v321_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_25
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/models/migrations/base"
10+
"code.gitea.io/gitea/modules/setting"
11+
"code.gitea.io/gitea/modules/timeutil"
12+
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func Test_UseLongTextInSomeColumnsAndFixBugs(t *testing.T) {
17+
if !setting.Database.Type.IsMySQL() {
18+
t.Skip("Only MySQL needs to change from TEXT to LONGTEXT")
19+
}
20+
21+
type ReviewState struct {
22+
ID int64 `xorm:"pk autoincr"`
23+
UserID int64 `xorm:"NOT NULL UNIQUE(pull_commit_user)"`
24+
PullID int64 `xorm:"NOT NULL INDEX UNIQUE(pull_commit_user) DEFAULT 0"` // Which PR was the review on?
25+
CommitSHA string `xorm:"NOT NULL VARCHAR(64) UNIQUE(pull_commit_user)"` // Which commit was the head commit for the review?
26+
UpdatedFiles map[string]int `xorm:"NOT NULL TEXT JSON"` // Stores for each of the changed files of a PR whether they have been viewed, changed since last viewed, or not viewed
27+
UpdatedUnix timeutil.TimeStamp `xorm:"updated"` // Is an accurate indicator of the order of commits as we do not expect it to be possible to make reviews on previous commits
28+
}
29+
30+
type PackageProperty struct {
31+
ID int64 `xorm:"pk autoincr"`
32+
RefType int `xorm:"INDEX NOT NULL"`
33+
RefID int64 `xorm:"INDEX NOT NULL"`
34+
Name string `xorm:"INDEX NOT NULL"`
35+
Value string `xorm:"TEXT NOT NULL"`
36+
}
37+
38+
type Notice struct {
39+
ID int64 `xorm:"pk autoincr"`
40+
Type int
41+
Description string `xorm:"LONGTEXT"`
42+
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
43+
}
44+
45+
// Prepare and load the testing database
46+
x, deferable := base.PrepareTestEnv(t, 0, new(ReviewState), new(PackageProperty), new(Notice))
47+
defer deferable()
48+
49+
assert.NoError(t, UseLongTextInSomeColumnsAndFixBugs(x))
50+
51+
tables, err := x.DBMetas()
52+
assert.NoError(t, err)
53+
54+
for _, table := range tables {
55+
switch table.Name {
56+
case "review_state":
57+
column := table.GetColumn("updated_files")
58+
assert.NotNil(t, column)
59+
assert.Equal(t, "LONGTEXT", column.SQLType.Name)
60+
case "package_property":
61+
column := table.GetColumn("value")
62+
assert.NotNil(t, column)
63+
assert.Equal(t, "LONGTEXT", column.SQLType.Name)
64+
case "notice":
65+
column := table.GetColumn("description")
66+
assert.NotNil(t, column)
67+
assert.Equal(t, "LONGTEXT", column.SQLType.Name)
68+
}
69+
}
70+
}

models/packages/package_property.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type PackageProperty struct {
3232
RefType PropertyType `xorm:"INDEX NOT NULL"`
3333
RefID int64 `xorm:"INDEX NOT NULL"`
3434
Name string `xorm:"INDEX NOT NULL"`
35-
Value string `xorm:"TEXT NOT NULL"`
35+
Value string `xorm:"LONGTEXT NOT NULL"`
3636
}
3737

3838
// InsertProperty creates a property

models/system/notice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const (
2929
type Notice struct {
3030
ID int64 `xorm:"pk autoincr"`
3131
Type NoticeType
32-
Description string `xorm:"TEXT"`
32+
Description string `xorm:"LONGTEXT"`
3333
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
3434
}
3535

modules/structs/issue.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ func (it IssueTemplate) Type() IssueTemplateType {
262262
// IssueMeta basic issue information
263263
// swagger:model
264264
type IssueMeta struct {
265-
Index int64 `json:"index"`
265+
Index int64 `json:"index"`
266+
// owner of the issue's repo
266267
Owner string `json:"owner"`
267268
Name string `json:"repo"`
268269
}

modules/structs/repo.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ type ExternalWiki struct {
4848

4949
// Repository represents a repository
5050
type Repository struct {
51-
ID int64 `json:"id"`
52-
Owner *User `json:"owner"`
53-
Name string `json:"name"`
54-
FullName string `json:"full_name"`
55-
Description string `json:"description"`
56-
Empty bool `json:"empty"`
57-
Private bool `json:"private"`
58-
Fork bool `json:"fork"`
59-
Template bool `json:"template"`
51+
ID int64 `json:"id"`
52+
Owner *User `json:"owner"`
53+
Name string `json:"name"`
54+
FullName string `json:"full_name"`
55+
Description string `json:"description"`
56+
Empty bool `json:"empty"`
57+
Private bool `json:"private"`
58+
Fork bool `json:"fork"`
59+
Template bool `json:"template"`
60+
// the original repository if this repository is a fork, otherwise null
6061
Parent *Repository `json:"parent,omitempty"`
6162
Mirror bool `json:"mirror"`
6263
Size int `json:"size"`
@@ -225,15 +226,13 @@ type EditRepoOption struct {
225226
EnablePrune *bool `json:"enable_prune,omitempty"`
226227
}
227228

228-
// GenerateRepoOption options when creating repository using a template
229+
// GenerateRepoOption options when creating a repository using a template
229230
// swagger:model
230231
type GenerateRepoOption struct {
231-
// The organization or person who will own the new repository
232+
// the organization's name or individual user's name who will own the new repository
232233
//
233234
// required: true
234235
Owner string `json:"owner"`
235-
// Name of the repository to create
236-
//
237236
// required: true
238237
// unique: true
239238
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
@@ -352,9 +351,9 @@ func (gt GitServiceType) Title() string {
352351
type MigrateRepoOptions struct {
353352
// required: true
354353
CloneAddr string `json:"clone_addr" binding:"Required"`
355-
// deprecated (only for backwards compatibility)
354+
// deprecated (only for backwards compatibility, use repo_owner instead)
356355
RepoOwnerID int64 `json:"uid"`
357-
// Name of User or Organisation who will own Repo after migration
356+
// the organization's name or individual user's name who will own the migrated repository
358357
RepoOwner string `json:"repo_owner"`
359358
// required: true
360359
RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`

0 commit comments

Comments
 (0)