mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
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>
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user