mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-10 05:24:18 +09:00
refactor: use WithRepo instead of WithDir for most git operations, clean up model migrations (#38555)
by the way, remove some unnecessary "models" imports from model migration package, fix migration test model init bug (modelmigration/migrationtest/tests.go)
This commit is contained in:
@@ -116,6 +116,10 @@ func RegisterModel(bean any, initFunc ...func() error) {
|
||||
}
|
||||
}
|
||||
|
||||
func ResetModels() {
|
||||
registeredModels, registeredInitFuncs = nil, nil
|
||||
}
|
||||
|
||||
// SyncAllTables sync the schemas of all tables, is required by unit test code
|
||||
func SyncAllTables() error {
|
||||
_, err := xormEngine.StoreEngine("InnoDB").SyncWithOptions(xorm.SyncOptions{
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/models/unit"
|
||||
)
|
||||
|
||||
// Init initialize model
|
||||
func Init(ctx context.Context) error {
|
||||
return unit.LoadUnitConfig()
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package models
|
||||
package repostats
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -2,7 +2,7 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package models
|
||||
package repostats
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"gitea.dev/models/db"
|
||||
issues_model "gitea.dev/models/issues"
|
||||
repo_model "gitea.dev/models/repo"
|
||||
"gitea.dev/models/unit"
|
||||
user_model "gitea.dev/models/user"
|
||||
"gitea.dev/modules/log"
|
||||
|
||||
@@ -21,11 +20,6 @@ import (
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
// Init initialize model
|
||||
func Init(ctx context.Context) error {
|
||||
return unit.LoadUnitConfig()
|
||||
}
|
||||
|
||||
type repoChecker struct {
|
||||
querySQL func(ctx context.Context) ([]int64, error)
|
||||
correctSQL func(ctx context.Context, id int64) error
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package models
|
||||
package repostats
|
||||
|
||||
import (
|
||||
"testing"
|
||||
Reference in New Issue
Block a user