mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-08-29 22:06:06 +02:00
Rename repo.GetOwner
to repo.LoadOwner
(#22967)
Fixes https://github.com/go-gitea/gitea/issues/22963 --------- Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
This commit is contained in:
parent
007d181bb5
commit
bd66fa586a
33 changed files with 68 additions and 68 deletions
|
@ -534,7 +534,7 @@ func NotifyWatchers(ctx context.Context, actions ...*Action) error {
|
||||||
repo = act.Repo
|
repo = act.Repo
|
||||||
|
|
||||||
// check repo owner exist.
|
// check repo owner exist.
|
||||||
if err := act.Repo.GetOwner(ctx); err != nil {
|
if err := act.Repo.LoadOwner(ctx); err != nil {
|
||||||
return fmt.Errorf("can't get repo owner: %w", err)
|
return fmt.Errorf("can't get repo owner: %w", err)
|
||||||
}
|
}
|
||||||
} else if act.Repo == nil {
|
} else if act.Repo == nil {
|
||||||
|
|
|
@ -314,8 +314,8 @@ type WhitelistOptions struct {
|
||||||
// This function also performs check if whitelist user and team's IDs have been changed
|
// This function also performs check if whitelist user and team's IDs have been changed
|
||||||
// to avoid unnecessary whitelist delete and regenerate.
|
// to avoid unnecessary whitelist delete and regenerate.
|
||||||
func UpdateProtectBranch(ctx context.Context, repo *repo_model.Repository, protectBranch *ProtectedBranch, opts WhitelistOptions) (err error) {
|
func UpdateProtectBranch(ctx context.Context, repo *repo_model.Repository, protectBranch *ProtectedBranch, opts WhitelistOptions) (err error) {
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
return fmt.Errorf("GetOwner: %v", err)
|
return fmt.Errorf("LoadOwner: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
whitelist, err := updateUserWhitelist(ctx, repo, protectBranch.WhitelistUserIDs, opts.UserIDs)
|
whitelist, err := updateUserWhitelist(ctx, repo, protectBranch.WhitelistUserIDs, opts.UserIDs)
|
||||||
|
|
|
@ -620,7 +620,7 @@ func (c *Comment) LoadAssigneeUserAndTeam() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = c.Issue.Repo.GetOwner(db.DefaultContext); err != nil {
|
if err = c.Issue.Repo.LoadOwner(db.DefaultContext); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,7 +824,7 @@ func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment,
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = opts.Repo.GetOwner(ctx); err != nil {
|
if err = opts.Repo.LoadOwner(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2099,7 +2099,7 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
|
||||||
resolved := make(map[string]bool, 10)
|
resolved := make(map[string]bool, 10)
|
||||||
var mentionTeams []string
|
var mentionTeams []string
|
||||||
|
|
||||||
if err := issue.Repo.GetOwner(ctx); err != nil {
|
if err := issue.Repo.LoadOwner(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -498,7 +498,7 @@ func (pr *PullRequest) SetMerged(ctx context.Context) (bool, error) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := pr.Issue.Repo.GetOwner(ctx); err != nil {
|
if err := pr.Issue.Repo.LoadOwner(ctx); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,8 @@ func updateUserAccess(accessMap map[int64]*userAccess, user *user_model.User, mo
|
||||||
// FIXME: do cross-comparison so reduce deletions and additions to the minimum?
|
// FIXME: do cross-comparison so reduce deletions and additions to the minimum?
|
||||||
func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap map[int64]*userAccess) (err error) {
|
func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap map[int64]*userAccess) (err error) {
|
||||||
minMode := perm.AccessModeRead
|
minMode := perm.AccessModeRead
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
return fmt.Errorf("GetOwner: %w", err)
|
return fmt.Errorf("LoadOwner: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the repo isn't private and isn't owned by a organization,
|
// If the repo isn't private and isn't owned by a organization,
|
||||||
|
@ -143,7 +143,7 @@ func refreshCollaboratorAccesses(ctx context.Context, repoID int64, accessMap ma
|
||||||
func RecalculateTeamAccesses(ctx context.Context, repo *repo_model.Repository, ignTeamID int64) (err error) {
|
func RecalculateTeamAccesses(ctx context.Context, repo *repo_model.Repository, ignTeamID int64) (err error) {
|
||||||
accessMap := make(map[int64]*userAccess, 20)
|
accessMap := make(map[int64]*userAccess, 20)
|
||||||
|
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !repo.Owner.IsOrganization() {
|
} else if !repo.Owner.IsOrganization() {
|
||||||
return fmt.Errorf("owner is not an organization: %d", repo.OwnerID)
|
return fmt.Errorf("owner is not an organization: %d", repo.OwnerID)
|
||||||
|
@ -199,7 +199,7 @@ func RecalculateUserAccess(ctx context.Context, repo *repo_model.Repository, uid
|
||||||
accessMode = collaborator.Mode
|
accessMode = collaborator.Mode
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if repo.Owner.IsOrganization() {
|
} else if repo.Owner.IsOrganization() {
|
||||||
var teams []organization.Team
|
var teams []organization.Team
|
||||||
|
|
|
@ -97,7 +97,7 @@ func TestRepository_RecalculateAccesses(t *testing.T) {
|
||||||
// test with organization repo
|
// test with organization repo
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 3})
|
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 3})
|
||||||
assert.NoError(t, repo1.GetOwner(db.DefaultContext))
|
assert.NoError(t, repo1.LoadOwner(db.DefaultContext))
|
||||||
|
|
||||||
_, err := db.GetEngine(db.DefaultContext).Delete(&repo_model.Collaboration{UserID: 2, RepoID: 3})
|
_, err := db.GetEngine(db.DefaultContext).Delete(&repo_model.Collaboration{UserID: 2, RepoID: 3})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -114,7 +114,7 @@ func TestRepository_RecalculateAccesses2(t *testing.T) {
|
||||||
// test with non-organization repo
|
// test with non-organization repo
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
|
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
|
||||||
assert.NoError(t, repo1.GetOwner(db.DefaultContext))
|
assert.NoError(t, repo1.LoadOwner(db.DefaultContext))
|
||||||
|
|
||||||
_, err := db.GetEngine(db.DefaultContext).Delete(&repo_model.Collaboration{UserID: 4, RepoID: 4})
|
_, err := db.GetEngine(db.DefaultContext).Delete(&repo_model.Collaboration{UserID: 4, RepoID: 4})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
|
@ -175,7 +175,7 @@ func GetUserRepoPermission(ctx context.Context, repo *repo_model.Repository, use
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ func GetUserRepoPermission(ctx context.Context, repo *repo_model.Repository, use
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !repo.Owner.IsOrganization() {
|
if !repo.Owner.IsOrganization() {
|
||||||
|
@ -281,7 +281,7 @@ func IsUserRealRepoAdmin(repo *repo_model.Repository, user *user_model.User) (bo
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.GetOwner(db.DefaultContext); err != nil {
|
if err := repo.LoadOwner(db.DefaultContext); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ func HasAccess(ctx context.Context, userID int64, repo *repo_model.Repository) (
|
||||||
|
|
||||||
// getUsersWithAccessMode returns users that have at least given access mode to the repository.
|
// getUsersWithAccessMode returns users that have at least given access mode to the repository.
|
||||||
func getUsersWithAccessMode(ctx context.Context, repo *repo_model.Repository, mode perm_model.AccessMode) (_ []*user_model.User, err error) {
|
func getUsersWithAccessMode(ctx context.Context, repo *repo_model.Repository, mode perm_model.AccessMode) (_ []*user_model.User, err error) {
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ func (repo *Repository) AfterLoad() {
|
||||||
// LoadAttributes loads attributes of the repository.
|
// LoadAttributes loads attributes of the repository.
|
||||||
func (repo *Repository) LoadAttributes(ctx context.Context) error {
|
func (repo *Repository) LoadAttributes(ctx context.Context) error {
|
||||||
// Load owner
|
// Load owner
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
return fmt.Errorf("load owner: %w", err)
|
return fmt.Errorf("load owner: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,8 +373,8 @@ func (repo *Repository) GetUnit(ctx context.Context, tp unit.Type) (*RepoUnit, e
|
||||||
return nil, ErrUnitTypeNotExist{tp}
|
return nil, ErrUnitTypeNotExist{tp}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOwner returns the repository owner
|
// LoadOwner loads owner user
|
||||||
func (repo *Repository) GetOwner(ctx context.Context) (err error) {
|
func (repo *Repository) LoadOwner(ctx context.Context) (err error) {
|
||||||
if repo.Owner != nil {
|
if repo.Owner != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ func (repo *Repository) GetOwner(ctx context.Context) (err error) {
|
||||||
// It creates a fake object that contains error details
|
// It creates a fake object that contains error details
|
||||||
// when error occurs.
|
// when error occurs.
|
||||||
func (repo *Repository) MustOwner(ctx context.Context) *user_model.User {
|
func (repo *Repository) MustOwner(ctx context.Context) *user_model.User {
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
return &user_model.User{
|
return &user_model.User{
|
||||||
Name: "error",
|
Name: "error",
|
||||||
FullName: err.Error(),
|
FullName: err.Error(),
|
||||||
|
|
|
@ -143,7 +143,7 @@ func ChangeRepositoryName(doer *user_model.User, repo *Repository, newRepoName s
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.GetOwner(db.DefaultContext); err != nil {
|
if err := repo.LoadOwner(db.DefaultContext); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ func GetWatchedRepos(ctx context.Context, userID int64, private bool, listOption
|
||||||
// GetRepoAssignees returns all users that have write access and can be assigned to issues
|
// GetRepoAssignees returns all users that have write access and can be assigned to issues
|
||||||
// of the repository,
|
// of the repository,
|
||||||
func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.User, err error) {
|
func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.User, err error) {
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.Us
|
||||||
// TODO: may be we should have a busy choice for users to block review request to them.
|
// TODO: may be we should have a busy choice for users to block review request to them.
|
||||||
func GetReviewers(ctx context.Context, repo *Repository, doerID, posterID int64) ([]*user_model.User, error) {
|
func GetReviewers(ctx context.Context, repo *Repository, doerID, posterID int64) ([]*user_model.User, error) {
|
||||||
// Get the owner of the repository - this often already pre-cached and if so saves complexity for the following queries
|
// Get the owner of the repository - this often already pre-cached and if so saves complexity for the following queries
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ func TestRepository_DeleteCollaboration(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
|
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
|
||||||
assert.NoError(t, repo.GetOwner(db.DefaultContext))
|
assert.NoError(t, repo.LoadOwner(db.DefaultContext))
|
||||||
assert.NoError(t, DeleteCollaboration(repo, 4))
|
assert.NoError(t, DeleteCollaboration(repo, 4))
|
||||||
unittest.AssertNotExistsBean(t, &repo_model.Collaboration{RepoID: repo.ID, UserID: 4})
|
unittest.AssertNotExistsBean(t, &repo_model.Collaboration{RepoID: repo.ID, UserID: 4})
|
||||||
|
|
||||||
|
|
|
@ -273,8 +273,8 @@ func RetrieveBaseRepo(ctx *Context, repo *repo_model.Repository) {
|
||||||
}
|
}
|
||||||
ctx.ServerError("GetBaseRepo", err)
|
ctx.ServerError("GetBaseRepo", err)
|
||||||
return
|
return
|
||||||
} else if err = repo.BaseRepo.GetOwner(ctx); err != nil {
|
} else if err = repo.BaseRepo.LoadOwner(ctx); err != nil {
|
||||||
ctx.ServerError("BaseRepo.GetOwner", err)
|
ctx.ServerError("BaseRepo.LoadOwner", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,8 +290,8 @@ func RetrieveTemplateRepo(ctx *Context, repo *repo_model.Repository) {
|
||||||
}
|
}
|
||||||
ctx.ServerError("GetTemplateRepo", err)
|
ctx.ServerError("GetTemplateRepo", err)
|
||||||
return
|
return
|
||||||
} else if err = templateRepo.GetOwner(ctx); err != nil {
|
} else if err = templateRepo.LoadOwner(ctx); err != nil {
|
||||||
ctx.ServerError("TemplateRepo.GetOwner", err)
|
ctx.ServerError("TemplateRepo.LoadOwner", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,8 +356,8 @@ func RedirectToRepo(ctx *Context, redirectRepoID int64) {
|
||||||
|
|
||||||
func repoAssignment(ctx *Context, repo *repo_model.Repository) {
|
func repoAssignment(ctx *Context, repo *repo_model.Repository) {
|
||||||
var err error
|
var err error
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
ctx.ServerError("GetOwner", err)
|
ctx.ServerError("LoadOwner", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ func checkDaemonExport(ctx context.Context, logger log.Logger, autofix bool) err
|
||||||
if owner, has := cache.Get(repo.OwnerID); has {
|
if owner, has := cache.Get(repo.OwnerID); has {
|
||||||
repo.Owner = owner.(*user_model.User)
|
repo.Owner = owner.(*user_model.User)
|
||||||
} else {
|
} else {
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cache.Add(repo.OwnerID, repo.Owner)
|
cache.Add(repo.OwnerID, repo.Owner)
|
||||||
|
|
|
@ -23,7 +23,7 @@ func TestRepository_AddCollaborator(t *testing.T) {
|
||||||
|
|
||||||
testSuccess := func(repoID, userID int64) {
|
testSuccess := func(repoID, userID int64) {
|
||||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: repoID})
|
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: repoID})
|
||||||
assert.NoError(t, repo.GetOwner(db.DefaultContext))
|
assert.NoError(t, repo.LoadOwner(db.DefaultContext))
|
||||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
|
||||||
assert.NoError(t, AddCollaborator(db.DefaultContext, repo, user))
|
assert.NoError(t, AddCollaborator(db.DefaultContext, repo, user))
|
||||||
unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: repoID}, &user_model.User{ID: userID})
|
unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: repoID}, &user_model.User{ID: userID})
|
||||||
|
|
|
@ -335,7 +335,7 @@ func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error {
|
||||||
|
|
||||||
// CheckDaemonExportOK creates/removes git-daemon-export-ok for git-daemon...
|
// CheckDaemonExportOK creates/removes git-daemon-export-ok for git-daemon...
|
||||||
func CheckDaemonExportOK(ctx context.Context, repo *repo_model.Repository) error {
|
func CheckDaemonExportOK(ctx context.Context, repo *repo_model.Repository) error {
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,8 +379,8 @@ func UpdateRepository(ctx context.Context, repo *repo_model.Repository, visibili
|
||||||
}
|
}
|
||||||
|
|
||||||
if visibilityChanged {
|
if visibilityChanged {
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
return fmt.Errorf("getOwner: %w", err)
|
return fmt.Errorf("LoadOwner: %w", err)
|
||||||
}
|
}
|
||||||
if repo.Owner.IsOrganization() {
|
if repo.Owner.IsOrganization() {
|
||||||
// Organization repository need to recalculate access table when visibility is changed.
|
// Organization repository need to recalculate access table when visibility is changed.
|
||||||
|
|
|
@ -16,7 +16,7 @@ func CanUserDelete(repo *repo_model.Repository, user *user_model.User) (bool, er
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.GetOwner(db.DefaultContext); err != nil {
|
if err := repo.LoadOwner(db.DefaultContext); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ func LoadUser(t *testing.T, ctx *context.Context, userID int64) {
|
||||||
// LoadGitRepo load a git repo into a test context. Requires that ctx.Repo has
|
// LoadGitRepo load a git repo into a test context. Requires that ctx.Repo has
|
||||||
// already been populated.
|
// already been populated.
|
||||||
func LoadGitRepo(t *testing.T, ctx *context.Context) {
|
func LoadGitRepo(t *testing.T, ctx *context.Context) {
|
||||||
assert.NoError(t, ctx.Repo.Repository.GetOwner(ctx))
|
assert.NoError(t, ctx.Repo.Repository.LoadOwner(ctx))
|
||||||
var err error
|
var err error
|
||||||
ctx.Repo.GitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.RepoPath())
|
ctx.Repo.GitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.RepoPath())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
|
@ -201,7 +201,7 @@ func Search(ctx *context.APIContext) {
|
||||||
|
|
||||||
results := make([]*api.Repository, len(repos))
|
results := make([]*api.Repository, len(repos))
|
||||||
for i, repo := range repos {
|
for i, repo := range repos {
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
ctx.JSON(http.StatusInternalServerError, api.SearchError{
|
ctx.JSON(http.StatusInternalServerError, api.SearchError{
|
||||||
OK: false,
|
OK: false,
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
|
|
|
@ -119,8 +119,8 @@ func ListMyRepos(ctx *context.APIContext) {
|
||||||
|
|
||||||
results := make([]*api.Repository, len(repos))
|
results := make([]*api.Repository, len(repos))
|
||||||
for i, repo := range repos {
|
for i, repo := range repos {
|
||||||
if err = repo.GetOwner(ctx); err != nil {
|
if err = repo.LoadOwner(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "GetOwner", err)
|
ctx.Error(http.StatusInternalServerError, "LoadOwner", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
accessMode, err := access_model.AccessLevel(ctx, ctx.Doer, repo)
|
accessMode, err := access_model.AccessLevel(ctx, ctx.Doer, repo)
|
||||||
|
|
|
@ -279,7 +279,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := ci.HeadRepo.GetOwner(ctx); err != nil {
|
if err := ci.HeadRepo.LoadOwner(ctx); err != nil {
|
||||||
if user_model.IsErrUserNotExist(err) {
|
if user_model.IsErrUserNotExist(err) {
|
||||||
ctx.NotFound("GetUserByName", nil)
|
ctx.NotFound("GetUserByName", nil)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -146,8 +146,8 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
|
||||||
|
|
||||||
// don't allow anonymous pulls if organization is not public
|
// don't allow anonymous pulls if organization is not public
|
||||||
if isPublicPull {
|
if isPublicPull {
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
ctx.ServerError("GetOwner", err)
|
ctx.ServerError("LoadOwner", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2157,8 +2157,8 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
if reviewID < 0 {
|
if reviewID < 0 {
|
||||||
// negative reviewIDs represent team requests
|
// negative reviewIDs represent team requests
|
||||||
if err := issue.Repo.GetOwner(ctx); err != nil {
|
if err := issue.Repo.LoadOwner(ctx); err != nil {
|
||||||
ctx.ServerError("issue.Repo.GetOwner", err)
|
ctx.ServerError("issue.Repo.LoadOwner", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,8 +119,8 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := forkRepo.GetOwner(ctx); err != nil {
|
if err := forkRepo.LoadOwner(ctx); err != nil {
|
||||||
ctx.ServerError("GetOwner", err)
|
ctx.ServerError("LoadOwner", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1315,8 +1315,8 @@ func CleanUpPullRequest(ctx *context.Context) {
|
||||||
} else if err = pr.LoadBaseRepo(ctx); err != nil {
|
} else if err = pr.LoadBaseRepo(ctx); err != nil {
|
||||||
ctx.ServerError("LoadBaseRepo", err)
|
ctx.ServerError("LoadBaseRepo", err)
|
||||||
return
|
return
|
||||||
} else if err = pr.HeadRepo.GetOwner(ctx); err != nil {
|
} else if err = pr.HeadRepo.LoadOwner(ctx); err != nil {
|
||||||
ctx.ServerError("HeadRepo.GetOwner", err)
|
ctx.ServerError("HeadRepo.LoadOwner", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -650,7 +650,7 @@ func SettingsPost(ctx *context.Context) {
|
||||||
ctx.Error(http.StatusNotFound)
|
ctx.Error(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
ctx.ServerError("Convert Fork", err)
|
ctx.ServerError("Convert Fork", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1033,8 +1033,8 @@ func Forks(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, fork := range forks {
|
for _, fork := range forks {
|
||||||
if err = fork.GetOwner(ctx); err != nil {
|
if err = fork.LoadOwner(ctx); err != nil {
|
||||||
ctx.ServerError("GetOwner", err)
|
ctx.ServerError("LoadOwner", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ func ToAPIIssue(ctx context.Context, issue *issues_model.Issue) *api.Issue {
|
||||||
if err := issue.LoadRepo(ctx); err != nil {
|
if err := issue.LoadRepo(ctx); err != nil {
|
||||||
return &api.Issue{}
|
return &api.Issue{}
|
||||||
}
|
}
|
||||||
if err := issue.Repo.GetOwner(ctx); err != nil {
|
if err := issue.Repo.LoadOwner(ctx); err != nil {
|
||||||
return &api.Issue{}
|
return &api.Issue{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ func innerToRepo(ctx context.Context, repo *repo_model.Repository, mode perm.Acc
|
||||||
hasProjects = true
|
hasProjects = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,8 +261,8 @@ func manuallyMerged(ctx context.Context, pr *issues_model.PullRequest) bool {
|
||||||
// When the commit author is unknown set the BaseRepo owner as merger
|
// When the commit author is unknown set the BaseRepo owner as merger
|
||||||
if merger == nil {
|
if merger == nil {
|
||||||
if pr.BaseRepo.Owner == nil {
|
if pr.BaseRepo.Owner == nil {
|
||||||
if err = pr.BaseRepo.GetOwner(ctx); err != nil {
|
if err = pr.BaseRepo.LoadOwner(ctx); err != nil {
|
||||||
log.Error("%-v BaseRepo.GetOwner: %v", pr, err)
|
log.Error("%-v BaseRepo.LoadOwner: %v", pr, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,8 +199,8 @@ func Merge(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.U
|
||||||
if err := pr.Issue.LoadRepo(hammerCtx); err != nil {
|
if err := pr.Issue.LoadRepo(hammerCtx); err != nil {
|
||||||
log.Error("LoadRepo for issue [%d]: %v", pr.ID, err)
|
log.Error("LoadRepo for issue [%d]: %v", pr.ID, err)
|
||||||
}
|
}
|
||||||
if err := pr.Issue.Repo.GetOwner(hammerCtx); err != nil {
|
if err := pr.Issue.Repo.LoadOwner(hammerCtx); err != nil {
|
||||||
log.Error("GetOwner for PR [%d]: %v", pr.ID, err)
|
log.Error("LoadOwner for PR [%d]: %v", pr.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if wasAutoMerged {
|
if wasAutoMerged {
|
||||||
|
@ -573,7 +573,7 @@ func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_mode
|
||||||
}
|
}
|
||||||
|
|
||||||
var headUser *user_model.User
|
var headUser *user_model.User
|
||||||
err = pr.HeadRepo.GetOwner(ctx)
|
err = pr.HeadRepo.LoadOwner(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !user_model.IsErrUserNotExist(err) {
|
if !user_model.IsErrUserNotExist(err) {
|
||||||
log.Error("Can't find user: %d for head repository - %v", pr.HeadRepo.OwnerID, err)
|
log.Error("Can't find user: %d for head repository - %v", pr.HeadRepo.OwnerID, err)
|
||||||
|
|
|
@ -38,12 +38,12 @@ func createTemporaryRepo(ctx context.Context, pr *issues_model.PullRequest) (str
|
||||||
return "", &repo_model.ErrRepoNotExist{
|
return "", &repo_model.ErrRepoNotExist{
|
||||||
ID: pr.BaseRepoID,
|
ID: pr.BaseRepoID,
|
||||||
}
|
}
|
||||||
} else if err := pr.HeadRepo.GetOwner(ctx); err != nil {
|
} else if err := pr.HeadRepo.LoadOwner(ctx); err != nil {
|
||||||
log.Error("HeadRepo.GetOwner: %v", err)
|
log.Error("HeadRepo.LoadOwner: %v", err)
|
||||||
return "", fmt.Errorf("HeadRepo.GetOwner: %w", err)
|
return "", fmt.Errorf("HeadRepo.LoadOwner: %w", err)
|
||||||
} else if err := pr.BaseRepo.GetOwner(ctx); err != nil {
|
} else if err := pr.BaseRepo.LoadOwner(ctx); err != nil {
|
||||||
log.Error("BaseRepo.GetOwner: %v", err)
|
log.Error("BaseRepo.LoadOwner: %v", err)
|
||||||
return "", fmt.Errorf("BaseRepo.GetOwner: %w", err)
|
return "", fmt.Errorf("BaseRepo.LoadOwner: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone base repo.
|
// Clone base repo.
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
// GetReviewerTeams get all teams can be requested to review
|
// GetReviewerTeams get all teams can be requested to review
|
||||||
func GetReviewerTeams(repo *repo_model.Repository) ([]*organization.Team, error) {
|
func GetReviewerTeams(repo *repo_model.Repository) ([]*organization.Team, error) {
|
||||||
if err := repo.GetOwner(db.DefaultContext); err != nil {
|
if err := repo.LoadOwner(db.DefaultContext); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !repo.Owner.IsOrganization() {
|
if !repo.Owner.IsOrganization() {
|
||||||
|
|
|
@ -26,7 +26,7 @@ var repoWorkingPool = sync.NewExclusivePool()
|
||||||
|
|
||||||
// TransferOwnership transfers all corresponding setting from old user to new one.
|
// TransferOwnership transfers all corresponding setting from old user to new one.
|
||||||
func TransferOwnership(ctx context.Context, doer, newOwner *user_model.User, repo *repo_model.Repository, teams []*organization.Team) error {
|
func TransferOwnership(ctx context.Context, doer, newOwner *user_model.User, repo *repo_model.Repository, teams []*organization.Team) error {
|
||||||
if err := repo.GetOwner(ctx); err != nil {
|
if err := repo.LoadOwner(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, team := range teams {
|
for _, team := range teams {
|
||||||
|
|
Loading…
Reference in a new issue