summaryrefslogtreecommitdiffstats
path: root/models/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 /models/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 'models/review.go')
-rw-r--r--models/review.go20
1 files changed, 6 insertions, 14 deletions
diff --git a/models/review.go b/models/review.go
index 88d0819089..8b0092b1ed 100644
--- a/models/review.go
+++ b/models/review.go
@@ -86,7 +86,8 @@ func init() {
db.RegisterModel(new(Review))
}
-func (r *Review) loadCodeComments(ctx context.Context) (err error) {
+// LoadCodeComments loads CodeComments
+func (r *Review) LoadCodeComments(ctx context.Context) (err error) {
if r.CodeComments != nil {
return
}
@@ -97,11 +98,6 @@ func (r *Review) loadCodeComments(ctx context.Context) (err error) {
return
}
-// LoadCodeComments loads CodeComments
-func (r *Review) LoadCodeComments() error {
- return r.loadCodeComments(db.DefaultContext)
-}
-
func (r *Review) loadIssue(e db.Engine) (err error) {
if r.Issue != nil {
return
@@ -137,12 +133,13 @@ func (r *Review) LoadReviewerTeam() error {
return r.loadReviewerTeam(db.GetEngine(db.DefaultContext))
}
-func (r *Review) loadAttributes(ctx context.Context) (err error) {
+// LoadAttributes loads all attributes except CodeComments
+func (r *Review) LoadAttributes(ctx context.Context) (err error) {
e := db.GetEngine(ctx)
if err = r.loadIssue(e); err != nil {
return
}
- if err = r.loadCodeComments(ctx); err != nil {
+ if err = r.LoadCodeComments(ctx); err != nil {
return
}
if err = r.loadReviewer(e); err != nil {
@@ -154,11 +151,6 @@ func (r *Review) loadAttributes(ctx context.Context) (err error) {
return
}
-// LoadAttributes loads all attributes except CodeComments
-func (r *Review) LoadAttributes() error {
- return r.loadAttributes(db.DefaultContext)
-}
-
func getReviewByID(e db.Engine, id int64) (*Review, error) {
review := new(Review)
if has, err := e.ID(id).Get(review); err != nil {
@@ -405,7 +397,7 @@ func SubmitReview(doer *user_model.User, issue *Issue, reviewType ReviewType, co
return nil, nil, err
}
} else {
- if err := review.loadCodeComments(ctx); err != nil {
+ if err := review.LoadCodeComments(ctx); err != nil {
return nil, nil, err
}
if reviewType != ReviewTypeApprove && len(review.CodeComments) == 0 && len(strings.TrimSpace(content)) == 0 {