mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-22 12:33:37 +00:00
refactor: clean up git repo and model migration packages (#38564)
enable the golangci depguard lint rule: deny "models" and its sub packages in "modelmigration" package.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package base
|
||||
|
||||
import (
|
||||
"gitea.dev/models/db" //nolint:depguard // allow to access db in migration
|
||||
"gitea.dev/modules/git/gitrepo"
|
||||
)
|
||||
|
||||
// HINT: MIGRATION-STRUCT-FROZEN: the structs used in migrations should not be affected by the changes happen in the future,
|
||||
// because the details can be different in different releases.
|
||||
// e.g. if one migration uses "User" model, it works in the early releases,
|
||||
// then one day, when the User model changes, the existing migration will break because it will use the new (incorrect) User model,
|
||||
// it should only use the old User model.
|
||||
//
|
||||
// Related: "models", "modules/structs", git repo directory layout on the disk, etc.
|
||||
//
|
||||
// If changes happen, the old migrations need to use a snapshot struct/function (copy the code and freeze)
|
||||
|
||||
type ResourceIndex = db.ResourceIndex
|
||||
|
||||
func LocalCodeGitRepo(ownerName, repoName string) gitrepo.RepositoryFacade {
|
||||
return gitrepo.CodeRepoByName(ownerName, repoName)
|
||||
}
|
||||
Reference in New Issue
Block a user