summaryrefslogtreecommitdiffstats
path: root/modules/convert/pull_review.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-01-19 23:26:57 +0000
committerGitHub <noreply@github.com>2022-01-19 23:26:57 +0000
commit5cb0c9aa0d7eed087055b1efca79628957207d36 (patch)
treed117a514e1f17e5f6bfcda1be273f6a971112663 /modules/convert/pull_review.go
parent4563148a61ba892e8f2bb66342f00a950bcd5315 (diff)
downloadgitea-5cb0c9aa0d7eed087055b1efca79628957207d36.tar.gz
gitea-5cb0c9aa0d7eed087055b1efca79628957207d36.zip
Propagate context and ensure git commands run in request context (#17868)
This PR continues the work in #17125 by progressively ensuring that git commands run within the request context. This now means that the if there is a git repo already open in the context it will be used instead of reopening it. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/convert/pull_review.go')
-rw-r--r--modules/convert/pull_review.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/convert/pull_review.go b/modules/convert/pull_review.go
index b99d7bead6..962aae58bb 100644
--- a/modules/convert/pull_review.go
+++ b/modules/convert/pull_review.go
@@ -5,6 +5,7 @@
package convert
import (
+ "context"
"strings"
"code.gitea.io/gitea/models"
@@ -13,8 +14,8 @@ import (
)
// ToPullReview convert a review to api format
-func ToPullReview(r *models.Review, doer *user_model.User) (*api.PullReview, error) {
- if err := r.LoadAttributes(); err != nil {
+func ToPullReview(ctx context.Context, r *models.Review, doer *user_model.User) (*api.PullReview, error) {
+ if err := r.LoadAttributes(ctx); err != nil {
if !user_model.IsErrUserNotExist(err) {
return nil, err
}
@@ -54,14 +55,14 @@ func ToPullReview(r *models.Review, doer *user_model.User) (*api.PullReview, err
}
// ToPullReviewList convert a list of review to it's api format
-func ToPullReviewList(rl []*models.Review, doer *user_model.User) ([]*api.PullReview, error) {
+func ToPullReviewList(ctx context.Context, rl []*models.Review, doer *user_model.User) ([]*api.PullReview, error) {
result := make([]*api.PullReview, 0, len(rl))
for i := range rl {
// show pending reviews only for the user who created them
if rl[i].Type == models.ReviewTypePending && !(doer.IsAdmin || doer.ID == rl[i].ReviewerID) {
continue
}
- r, err := ToPullReview(rl[i], doer)
+ r, err := ToPullReview(ctx, rl[i], doer)
if err != nil {
return nil, err
}
@@ -71,8 +72,8 @@ func ToPullReviewList(rl []*models.Review, doer *user_model.User) ([]*api.PullRe
}
// ToPullReviewCommentList convert the CodeComments of an review to it's api format
-func ToPullReviewCommentList(review *models.Review, doer *user_model.User) ([]*api.PullReviewComment, error) {
- if err := review.LoadAttributes(); err != nil {
+func ToPullReviewCommentList(ctx context.Context, review *models.Review, doer *user_model.User) ([]*api.PullReviewComment, error) {
+ if err := review.LoadAttributes(ctx); err != nil {
if !user_model.IsErrUserNotExist(err) {
return nil, err
}