mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 05:52:43 +00:00
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
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/cache"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
|
@ -76,7 +77,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
repo, err := models.GetRepositoryByOwnerAndName(optsList[0].RepoUserName, optsList[0].RepoName)
|
||||
repo, err := repo_model.GetRepositoryByOwnerAndName(optsList[0].RepoUserName, optsList[0].RepoName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetRepositoryByOwnerAndName failed: %v", err)
|
||||
}
|
||||
|
@ -88,7 +89,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
|||
}
|
||||
defer gitRepo.Close()
|
||||
|
||||
if err = repo.UpdateSize(db.DefaultContext); err != nil {
|
||||
if err = models.UpdateRepoSize(db.DefaultContext, repo); err != nil {
|
||||
log.Error("Failed to update size for repository: %v", err)
|
||||
}
|
||||
|
||||
|
@ -209,7 +210,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
|||
commits.CompareURL = repo.ComposeCompareURL(opts.OldCommitID, opts.NewCommitID)
|
||||
notification.NotifyPushCommits(pusher, repo, opts, commits)
|
||||
|
||||
if err = models.RemoveDeletedBranch(repo.ID, branch); err != nil {
|
||||
if err = models.RemoveDeletedBranchByName(repo.ID, branch); err != nil {
|
||||
log.Error("models.RemoveDeletedBranch %s/%s failed: %v", repo.ID, branch, err)
|
||||
}
|
||||
|
||||
|
@ -246,7 +247,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
|||
}
|
||||
|
||||
// PushUpdateAddDeleteTags updates a number of added and delete tags
|
||||
func PushUpdateAddDeleteTags(repo *models.Repository, gitRepo *git.Repository, addTags, delTags []string) error {
|
||||
func PushUpdateAddDeleteTags(repo *repo_model.Repository, gitRepo *git.Repository, addTags, delTags []string) error {
|
||||
return db.WithTx(func(ctx context.Context) error {
|
||||
if err := models.PushUpdateDeleteTagsContext(ctx, repo, delTags); err != nil {
|
||||
return err
|
||||
|
@ -256,7 +257,7 @@ func PushUpdateAddDeleteTags(repo *models.Repository, gitRepo *git.Repository, a
|
|||
}
|
||||
|
||||
// pushUpdateAddTags updates a number of add tags
|
||||
func pushUpdateAddTags(ctx context.Context, repo *models.Repository, gitRepo *git.Repository, tags []string) error {
|
||||
func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, tags []string) error {
|
||||
if len(tags) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue