Skip to content

Commit d4a502c

Browse files
committed
revert unnecessary change
1 parent 9e5275c commit d4a502c

File tree

21 files changed

+51
-65
lines changed

21 files changed

+51
-65
lines changed

cmd/cert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
var CmdCert = cli.Command{
2929
Name: "cert",
3030
Usage: "Generate self-signed certificate",
31-
Description: `Generate a self-signed x.509 certificate for a TLS server.
31+
Description: `Generate a self-signed X.509 certificate for a TLS server.
3232
Outputs to 'cert.pem' and 'key.pem' and will overwrite existing files.`,
3333
Action: runCert,
3434
Flags: []cli.Flag{

models/consistency.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@ func getCount(t *testing.T, e db.Engine, bean interface{}) int64 {
6464
return count
6565
}
6666

67-
// AssertCount test the count of database entries matching bean
68-
func AssertCount(t *testing.T, bean interface{}, expected int) {
67+
// assertCount test the count of database entries matching bean
68+
func assertCount(t *testing.T, bean interface{}, expected int) {
6969
assert.EqualValues(t, expected, getCount(t, db.DefaultContext().Engine(), bean),
7070
"Failed consistency test, the counted bean (of type %T) was %+v", bean, bean)
7171
}
7272

7373
func (user *User) checkForConsistency(t *testing.T) {
74-
db.AssertCount(t, &Repository{OwnerID: user.ID}, user.NumRepos)
75-
db.AssertCount(t, &Star{UID: user.ID}, user.NumStars)
76-
db.AssertCount(t, &OrgUser{OrgID: user.ID}, user.NumMembers)
77-
db.AssertCount(t, &Team{OrgID: user.ID}, user.NumTeams)
78-
db.AssertCount(t, &Follow{UserID: user.ID}, user.NumFollowing)
79-
db.AssertCount(t, &Follow{FollowID: user.ID}, user.NumFollowers)
74+
assertCount(t, &Repository{OwnerID: user.ID}, user.NumRepos)
75+
assertCount(t, &Star{UID: user.ID}, user.NumStars)
76+
assertCount(t, &OrgUser{OrgID: user.ID}, user.NumMembers)
77+
assertCount(t, &Team{OrgID: user.ID}, user.NumTeams)
78+
assertCount(t, &Follow{UserID: user.ID}, user.NumFollowing)
79+
assertCount(t, &Follow{FollowID: user.ID}, user.NumFollowers)
8080
if user.Type != UserTypeOrganization {
8181
assert.EqualValues(t, 0, user.NumMembers)
8282
assert.EqualValues(t, 0, user.NumTeams)
@@ -85,9 +85,9 @@ func (user *User) checkForConsistency(t *testing.T) {
8585

8686
func (repo *Repository) checkForConsistency(t *testing.T) {
8787
assert.Equal(t, repo.LowerName, strings.ToLower(repo.Name), "repo: %+v", repo)
88-
db.AssertCount(t, &Star{RepoID: repo.ID}, repo.NumStars)
89-
db.AssertCount(t, &Milestone{RepoID: repo.ID}, repo.NumMilestones)
90-
db.AssertCount(t, &Repository{ForkID: repo.ID}, repo.NumForks)
88+
assertCount(t, &Star{RepoID: repo.ID}, repo.NumStars)
89+
assertCount(t, &Milestone{RepoID: repo.ID}, repo.NumMilestones)
90+
assertCount(t, &Repository{ForkID: repo.ID}, repo.NumForks)
9191
if repo.IsFork {
9292
db.AssertExistsAndLoadBean(t, &Repository{ID: repo.ForkID})
9393
}
@@ -134,7 +134,7 @@ func (pr *PullRequest) checkForConsistency(t *testing.T) {
134134
}
135135

136136
func (milestone *Milestone) checkForConsistency(t *testing.T) {
137-
db.AssertCount(t, &Issue{MilestoneID: milestone.ID}, milestone.NumIssues)
137+
assertCount(t, &Issue{MilestoneID: milestone.ID}, milestone.NumIssues)
138138

139139
actual := getCount(t, db.DefaultContext().Engine().Where("is_closed=?", true), &Issue{MilestoneID: milestone.ID})
140140
assert.EqualValues(t, milestone.NumClosedIssues, actual,
@@ -167,8 +167,8 @@ func (label *Label) checkForConsistency(t *testing.T) {
167167
}
168168

169169
func (team *Team) checkForConsistency(t *testing.T) {
170-
db.AssertCount(t, &TeamUser{TeamID: team.ID}, team.NumMembers)
171-
db.AssertCount(t, &TeamRepo{TeamID: team.ID}, team.NumRepos)
170+
assertCount(t, &TeamUser{TeamID: team.ID}, team.NumMembers)
171+
assertCount(t, &TeamRepo{TeamID: team.ID}, team.NumRepos)
172172
}
173173

174174
func (action *Action) checkForConsistency(t *testing.T) {

models/db/main_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package db
6+
7+
import (
8+
"path/filepath"
9+
"testing"
10+
)
11+
12+
func TestMain(m *testing.M) {
13+
MainTest(m, filepath.Join("..", ".."))
14+
}

models/migrations/migrations.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ var migrations = []Migration{
346346

347347
// GetCurrentDBVersion returns the current db version
348348
func GetCurrentDBVersion(x *xorm.Engine) (int64, error) {
349-
if err := x.Sync2(new(Version)); err != nil {
349+
if err := x.Sync(new(Version)); err != nil {
350350
return -1, fmt.Errorf("sync: %v", err)
351351
}
352352

@@ -394,7 +394,7 @@ func EnsureUpToDate(x *xorm.Engine) error {
394394
func Migrate(x *xorm.Engine) error {
395395
// Set a new clean the default mapper to GonicMapper as that is the default for Gitea.
396396
x.SetMapper(names.GonicMapper{})
397-
if err := x.Sync2(new(Version)); err != nil {
397+
if err := x.Sync(new(Version)); err != nil {
398398
return fmt.Errorf("sync: %v", err)
399399
}
400400

models/migrations/v121.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addIsRestricted(x *xorm.Engine) error {
1210
// User see models/user.go

models/migrations/v133.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addEmailHashTable(x *xorm.Engine) error {
1210
// EmailHash represents a pre-generated hash map

models/migrations/v152.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addTrustModelToRepository(x *xorm.Engine) error {
1210
type Repository struct {

models/migrations/v188.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addKeyIsVerified(x *xorm.Engine) error {
1210
type GPGKey struct {

models/migrations/v74.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addApprovalWhitelistsToProtectedBranches(x *xorm.Engine) error {
1210
type ProtectedBranch struct {

models/migrations/v80.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addIsLockedToIssues(x *xorm.Engine) error {
1210
// Issue see models/issue.go

models/migrations/v89.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addOriginalMigrationInfo(x *xorm.Engine) error {
1210
// Issue see models/issue.go

models/migrations/v90.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func changeSomeColumnsLengthOfRepo(x *xorm.Engine) error {
1210
type Repository struct {

models/migrations/v91.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addIndexOnRepositoryAndComment(x *xorm.Engine) error {
1210
type Repository struct {

models/migrations/v93.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addEmailNotificationEnabledToUser(x *xorm.Engine) error {
1210
// User see models/user.go

models/migrations/v94.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addStatusCheckColumnsForProtectedBranches(x *xorm.Engine) error {
1210
type ProtectedBranch struct {

models/migrations/v95.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addCrossReferenceColumns(x *xorm.Engine) error {
1210
// Comment see models/comment.go

models/migrations/v97.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addRepoAdminChangeTeamAccessColumnForUser(x *xorm.Engine) error {
1210
type User struct {

models/migrations/v98.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
package migrations
66

7-
import (
8-
"xorm.io/xorm"
9-
)
7+
import "xorm.io/xorm"
108

119
func addOriginalAuthorOnMigratedReleases(x *xorm.Engine) error {
1210
type Release struct {

models/models.go renamed to routers/common/db.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5-
package models
5+
package common
66

77
import (
88
"context"
@@ -15,8 +15,8 @@ import (
1515
"code.gitea.io/gitea/modules/setting"
1616
)
1717

18-
// InitEngine In case of problems connecting to DB, retry connection. Eg, PGSQL in Docker Container on Synology
19-
func InitEngine(ctx context.Context) (err error) {
18+
// InitDBEngine In case of problems connecting to DB, retry connection. Eg, PGSQL in Docker Container on Synology
19+
func InitDBEngine(ctx context.Context) (err error) {
2020
log.Info("Beginning ORM engine initialization.")
2121
for i := 0; i < setting.Database.DBConnectRetries; i++ {
2222
select {

routers/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func GlobalInit(ctx context.Context) {
9898
} else if setting.Database.UseSQLite3 {
9999
log.Fatal("SQLite3 is set in settings but NOT Supported")
100100
}
101-
if err := models.InitEngine(ctx); err == nil {
101+
if err := common.InitDBEngine(ctx); err == nil {
102102
log.Info("ORM engine initialization successful!")
103103
} else {
104104
log.Fatal("ORM engine initialization failed: %v", err)

routers/install/setting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ package install
77
import (
88
"context"
99

10-
"code.gitea.io/gitea/models"
1110
"code.gitea.io/gitea/modules/log"
1211
"code.gitea.io/gitea/modules/setting"
1312
"code.gitea.io/gitea/modules/svg"
1413
"code.gitea.io/gitea/modules/translation"
14+
"code.gitea.io/gitea/routers/common"
1515
)
1616

1717
// PreloadSettings preloads the configuration to check if we need to run install
@@ -41,7 +41,7 @@ func ReloadSettings(ctx context.Context) {
4141
setting.NewContext()
4242
setting.InitDBConfig()
4343
if setting.InstallLock {
44-
if err := models.InitEngine(ctx); err == nil {
44+
if err := common.InitDBEngine(ctx); err == nil {
4545
log.Info("ORM engine initialization successful!")
4646
} else {
4747
log.Fatal("ORM engine initialization failed: %v", err)

0 commit comments

Comments
 (0)