diff options
Diffstat (limited to 'services/repository/transfer.go')
-rw-r--r-- | services/repository/transfer.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/services/repository/transfer.go b/services/repository/transfer.go index d6aea70ffd..b60338300b 100644 --- a/services/repository/transfer.go +++ b/services/repository/transfer.go @@ -8,7 +8,9 @@ import ( "fmt" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/perm" + repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/sync" @@ -18,8 +20,8 @@ import ( var repoWorkingPool = sync.NewExclusivePool() // TransferOwnership transfers all corresponding setting from old user to new one. -func TransferOwnership(doer, newOwner *user_model.User, repo *models.Repository, teams []*models.Team) error { - if err := repo.GetOwner(); err != nil { +func TransferOwnership(doer, newOwner *user_model.User, repo *repo_model.Repository, teams []*models.Team) error { + if err := repo.GetOwner(db.DefaultContext); err != nil { return err } for _, team := range teams { @@ -37,7 +39,7 @@ func TransferOwnership(doer, newOwner *user_model.User, repo *models.Repository, } repoWorkingPool.CheckOut(fmt.Sprint(repo.ID)) - newRepo, err := models.GetRepositoryByID(repo.ID) + newRepo, err := repo_model.GetRepositoryByID(repo.ID) if err != nil { return err } @@ -54,7 +56,7 @@ func TransferOwnership(doer, newOwner *user_model.User, repo *models.Repository, } // ChangeRepositoryName changes all corresponding setting from old repository name to new one. -func ChangeRepositoryName(doer *user_model.User, repo *models.Repository, newRepoName string) error { +func ChangeRepositoryName(doer *user_model.User, repo *repo_model.Repository, newRepoName string) error { oldRepoName := repo.Name // Change repository directory name. We must lock the local copy of the @@ -75,7 +77,7 @@ func ChangeRepositoryName(doer *user_model.User, repo *models.Repository, newRep // StartRepositoryTransfer transfer a repo from one owner to a new one. // it make repository into pending transfer state, if doer can not create repo for new owner. -func StartRepositoryTransfer(doer, newOwner *user_model.User, repo *models.Repository, teams []*models.Team) error { +func StartRepositoryTransfer(doer, newOwner *user_model.User, repo *repo_model.Repository, teams []*models.Team) error { if err := models.TestRepositoryReadyForTransfer(repo.Status); err != nil { return err } @@ -102,16 +104,16 @@ func StartRepositoryTransfer(doer, newOwner *user_model.User, repo *models.Repos return err } if !hasAccess { - if err := repo.AddCollaborator(newOwner); err != nil { + if err := models.AddCollaborator(repo, newOwner); err != nil { return err } - if err := repo.ChangeCollaborationAccessMode(newOwner.ID, perm.AccessModeRead); err != nil { + if err := models.ChangeCollaborationAccessMode(repo, newOwner.ID, perm.AccessModeRead); err != nil { return err } } // Make repo as pending for transfer - repo.Status = models.RepositoryPendingTransfer + repo.Status = repo_model.RepositoryPendingTransfer if err := models.CreatePendingRepositoryTransfer(doer, newOwner, repo.ID, teams); err != nil { return err } |