forked from forgejo/forgejo
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
This commit is contained in:
parent
fb8166c6c6
commit
719bddcd76
301 changed files with 3193 additions and 2919 deletions
|
@ -16,6 +16,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
|
@ -96,7 +97,7 @@ func Dashboard(ctx *context.Context) {
|
|||
}
|
||||
|
||||
var err error
|
||||
var mirrors []*models.Repository
|
||||
var mirrors []*repo_model.Repository
|
||||
if ctxUser.IsOrganization() {
|
||||
var env models.AccessibleReposEnvironment
|
||||
if ctx.Org.Team != nil {
|
||||
|
@ -114,7 +115,7 @@ func Dashboard(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
} else {
|
||||
mirrors, err = models.GetUserMirrorRepositories(ctxUser.ID)
|
||||
mirrors, err = repo_model.GetUserMirrorRepositories(ctxUser.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserMirrorRepositories", err)
|
||||
return
|
||||
|
@ -122,7 +123,7 @@ func Dashboard(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["MaxShowRepoNum"] = setting.UI.User.RepoPagingNum
|
||||
|
||||
if err := models.MirrorRepositoryList(mirrors).LoadAttributes(); err != nil {
|
||||
if err := repo_model.MirrorRepositoryList(mirrors).LoadAttributes(); err != nil {
|
||||
ctx.ServerError("MirrorRepositoryList.LoadAttributes", err)
|
||||
return
|
||||
}
|
||||
|
@ -524,7 +525,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
|
|||
// showReposMap maps repository IDs to their Repository pointers.
|
||||
showReposMap, err := repoIDMap(ctxUser, issueCountByRepo, unitType)
|
||||
if err != nil {
|
||||
if models.IsErrRepoNotExist(err) {
|
||||
if repo_model.IsErrRepoNotExist(err) {
|
||||
ctx.NotFound("GetRepositoryByID", err)
|
||||
return
|
||||
}
|
||||
|
@ -795,15 +796,15 @@ func issueIDsFromSearch(ctxUser *user_model.User, keyword string, opts *models.I
|
|||
return issueIDsFromSearch, nil
|
||||
}
|
||||
|
||||
func repoIDMap(ctxUser *user_model.User, issueCountByRepo map[int64]int64, unitType unit.Type) (map[int64]*models.Repository, error) {
|
||||
repoByID := make(map[int64]*models.Repository, len(issueCountByRepo))
|
||||
func repoIDMap(ctxUser *user_model.User, issueCountByRepo map[int64]int64, unitType unit.Type) (map[int64]*repo_model.Repository, error) {
|
||||
repoByID := make(map[int64]*repo_model.Repository, len(issueCountByRepo))
|
||||
for id := range issueCountByRepo {
|
||||
if id <= 0 {
|
||||
continue
|
||||
}
|
||||
if _, ok := repoByID[id]; !ok {
|
||||
repo, err := models.GetRepositoryByID(id)
|
||||
if models.IsErrRepoNotExist(err) {
|
||||
repo, err := repo_model.GetRepositoryByID(id)
|
||||
if repo_model.IsErrRepoNotExist(err) {
|
||||
return nil, err
|
||||
} else if err != nil {
|
||||
return nil, fmt.Errorf("GetRepositoryByID: [%d]%v", id, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue