summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/pull_review.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/repo/pull_review.go')
-rw-r--r--routers/api/v1/repo/pull_review.go29
1 files changed, 15 insertions, 14 deletions
diff --git a/routers/api/v1/repo/pull_review.go b/routers/api/v1/repo/pull_review.go
index ec5f045647..9eb63bafad 100644
--- a/routers/api/v1/repo/pull_review.go
+++ b/routers/api/v1/repo/pull_review.go
@@ -97,7 +97,7 @@ func ListPullReviews(ctx *context.APIContext) {
return
}
- apiReviews, err := convert.ToPullReviewList(allReviews, ctx.User)
+ apiReviews, err := convert.ToPullReviewList(ctx, allReviews, ctx.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "convertToPullReviewList", err)
return
@@ -148,7 +148,7 @@ func GetPullReview(ctx *context.APIContext) {
return
}
- apiReview, err := convert.ToPullReview(review, ctx.User)
+ apiReview, err := convert.ToPullReview(ctx, review, ctx.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "convertToPullReview", err)
return
@@ -198,7 +198,7 @@ func GetPullReviewComments(ctx *context.APIContext) {
return
}
- apiComments, err := convert.ToPullReviewCommentList(review, ctx.User)
+ apiComments, err := convert.ToPullReviewCommentList(ctx, review, ctx.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "convertToPullReviewCommentList", err)
return
@@ -328,12 +328,13 @@ func CreatePullReview(ctx *context.APIContext) {
// if CommitID is empty, set it as lastCommitID
if opts.CommitID == "" {
- gitRepo, err := git.OpenRepository(pr.Issue.Repo.RepoPath())
+
+ gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, pr.Issue.Repo.RepoPath())
if err != nil {
ctx.Error(http.StatusInternalServerError, "git.OpenRepository", err)
return
}
- defer gitRepo.Close()
+ defer closer.Close()
headCommitID, err := gitRepo.GetRefCommitID(pr.GetGitRefName())
if err != nil {
@@ -351,7 +352,7 @@ func CreatePullReview(ctx *context.APIContext) {
line = c.OldLineNum * -1
}
- if _, err := pull_service.CreateCodeComment(
+ if _, err := pull_service.CreateCodeComment(ctx,
ctx.User,
ctx.Repo.GitRepo,
pr.Issue,
@@ -368,14 +369,14 @@ func CreatePullReview(ctx *context.APIContext) {
}
// create review and associate all pending review comments
- review, _, err := pull_service.SubmitReview(ctx.User, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, opts.CommitID, nil)
+ review, _, err := pull_service.SubmitReview(ctx, ctx.User, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, opts.CommitID, nil)
if err != nil {
ctx.Error(http.StatusInternalServerError, "SubmitReview", err)
return
}
// convert response
- apiReview, err := convert.ToPullReview(review, ctx.User)
+ apiReview, err := convert.ToPullReview(ctx, review, ctx.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "convertToPullReview", err)
return
@@ -456,14 +457,14 @@ func SubmitPullReview(ctx *context.APIContext) {
}
// create review and associate all pending review comments
- review, _, err = pull_service.SubmitReview(ctx.User, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, headCommitID, nil)
+ review, _, err = pull_service.SubmitReview(ctx, ctx.User, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, headCommitID, nil)
if err != nil {
ctx.Error(http.StatusInternalServerError, "SubmitReview", err)
return
}
// convert response
- apiReview, err := convert.ToPullReview(review, ctx.User)
+ apiReview, err := convert.ToPullReview(ctx, review, ctx.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "convertToPullReview", err)
return
@@ -555,7 +556,7 @@ func prepareSingleReview(ctx *context.APIContext) (*models.Review, *models.PullR
return nil, nil, true
}
- if err := review.LoadAttributes(); err != nil && !user_model.IsErrUserNotExist(err) {
+ if err := review.LoadAttributes(ctx); err != nil && !user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusInternalServerError, "ReviewLoadAttributes", err)
return nil, nil, true
}
@@ -765,7 +766,7 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions
}
if isAdd {
- apiReviews, err := convert.ToPullReviewList(reviews, ctx.User)
+ apiReviews, err := convert.ToPullReviewList(ctx, reviews, ctx.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "convertToPullReviewList", err)
return
@@ -883,7 +884,7 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss bool) {
return
}
- _, err := pull_service.DismissReview(review.ID, msg, ctx.User, isDismiss)
+ _, err := pull_service.DismissReview(ctx, review.ID, msg, ctx.User, isDismiss)
if err != nil {
ctx.Error(http.StatusInternalServerError, "pull_service.DismissReview", err)
return
@@ -895,7 +896,7 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss bool) {
}
// convert response
- apiReview, err := convert.ToPullReview(review, ctx.User)
+ apiReview, err := convert.ToPullReview(ctx, review, ctx.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "convertToPullReview", err)
return