Use for a repo action one database transaction (#19576)

... more context

(part of #9307)
This commit is contained in:
6543
2022-05-03 21:46:28 +02:00
committed by GitHub
parent 730420b6b3
commit 92f139d091
29 changed files with 270 additions and 260 deletions

View File

@@ -455,8 +455,8 @@ func CreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_
}
}
if isAdmin, err := isUserRepoAdmin(ctx, repo, doer); err != nil {
return fmt.Errorf("isUserRepoAdmin: %v", err)
if isAdmin, err := IsUserRepoAdminCtx(ctx, repo, doer); err != nil {
return fmt.Errorf("IsUserRepoAdminCtx: %v", err)
} else if !isAdmin {
// Make creator repo admin if it wasn't assigned automatically
if err = addCollaborator(ctx, repo, doer); err != nil {
@@ -1215,7 +1215,7 @@ func DeleteDeployKey(ctx context.Context, doer *user_model.User, id int64) error
if err != nil {
return fmt.Errorf("GetRepositoryByID: %v", err)
}
has, err := isUserRepoAdmin(ctx, repo, doer)
has, err := IsUserRepoAdminCtx(ctx, repo, doer)
if err != nil {
return fmt.Errorf("GetUserRepoPermission: %v", err)
} else if !has {