1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Add context.Context to more methods (#21546)

This PR adds a context parameter to a bunch of methods. Some helper
`xxxCtx()` methods got replaced with the normal name now.

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
KN4CK3R
2022-11-19 09:12:33 +01:00
committed by GitHub
parent fefdb7ffd1
commit 044c754ea5
148 changed files with 1411 additions and 1564 deletions

View File

@@ -427,7 +427,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
requiredApprovals = form.RequiredApprovals
}
whitelistUsers, err := user_model.GetUserIDsByNames(form.PushWhitelistUsernames, false)
whitelistUsers, err := user_model.GetUserIDsByNames(ctx, form.PushWhitelistUsernames, false)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "User does not exist", err)
@@ -436,7 +436,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetUserIDsByNames", err)
return
}
mergeWhitelistUsers, err := user_model.GetUserIDsByNames(form.MergeWhitelistUsernames, false)
mergeWhitelistUsers, err := user_model.GetUserIDsByNames(ctx, form.MergeWhitelistUsernames, false)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "User does not exist", err)
@@ -445,7 +445,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetUserIDsByNames", err)
return
}
approvalsWhitelistUsers, err := user_model.GetUserIDsByNames(form.ApprovalsWhitelistUsernames, false)
approvalsWhitelistUsers, err := user_model.GetUserIDsByNames(ctx, form.ApprovalsWhitelistUsernames, false)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "User does not exist", err)
@@ -656,7 +656,7 @@ func EditBranchProtection(ctx *context.APIContext) {
var whitelistUsers []int64
if form.PushWhitelistUsernames != nil {
whitelistUsers, err = user_model.GetUserIDsByNames(form.PushWhitelistUsernames, false)
whitelistUsers, err = user_model.GetUserIDsByNames(ctx, form.PushWhitelistUsernames, false)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "User does not exist", err)
@@ -670,7 +670,7 @@ func EditBranchProtection(ctx *context.APIContext) {
}
var mergeWhitelistUsers []int64
if form.MergeWhitelistUsernames != nil {
mergeWhitelistUsers, err = user_model.GetUserIDsByNames(form.MergeWhitelistUsernames, false)
mergeWhitelistUsers, err = user_model.GetUserIDsByNames(ctx, form.MergeWhitelistUsernames, false)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "User does not exist", err)
@@ -684,7 +684,7 @@ func EditBranchProtection(ctx *context.APIContext) {
}
var approvalsWhitelistUsers []int64
if form.ApprovalsWhitelistUsernames != nil {
approvalsWhitelistUsers, err = user_model.GetUserIDsByNames(form.ApprovalsWhitelistUsernames, false)
approvalsWhitelistUsers, err = user_model.GetUserIDsByNames(ctx, form.ApprovalsWhitelistUsernames, false)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "User does not exist", err)

View File

@@ -59,7 +59,7 @@ func ListForks(ctx *context.APIContext) {
}
apiForks := make([]*api.Repository, len(forks))
for i, fork := range forks {
access, err := access_model.AccessLevel(ctx.Doer, fork)
access, err := access_model.AccessLevel(ctx, ctx.Doer, fork)
if err != nil {
ctx.Error(http.StatusInternalServerError, "AccessLevel", err)
return

View File

@@ -179,7 +179,7 @@ func SearchIssues(ctx *context.APIContext) {
repoCond := repo_model.SearchRepositoryCondition(opts)
repoIDs, _, err := repo_model.SearchRepositoryIDs(opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "SearchRepositoryByName", err)
ctx.Error(http.StatusInternalServerError, "SearchRepositoryIDs", err)
return
}
@@ -268,7 +268,7 @@ func SearchIssues(ctx *context.APIContext) {
issuesOpt.ReviewRequestedID = ctxUserID
}
if issues, err = issues_model.Issues(issuesOpt); err != nil {
if issues, err = issues_model.Issues(ctx, issuesOpt); err != nil {
ctx.Error(http.StatusInternalServerError, "Issues", err)
return
}
@@ -276,7 +276,7 @@ func SearchIssues(ctx *context.APIContext) {
issuesOpt.ListOptions = db.ListOptions{
Page: -1,
}
if filteredCount, err = issues_model.CountIssues(issuesOpt); err != nil {
if filteredCount, err = issues_model.CountIssues(ctx, issuesOpt); err != nil {
ctx.Error(http.StatusInternalServerError, "CountIssues", err)
return
}
@@ -284,7 +284,7 @@ func SearchIssues(ctx *context.APIContext) {
ctx.SetLinkHeader(int(filteredCount), limit)
ctx.SetTotalCountHeader(filteredCount)
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(issues))
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
}
// ListIssues list the issues of a repository
@@ -477,7 +477,7 @@ func ListIssues(ctx *context.APIContext) {
MentionedID: mentionedByID,
}
if issues, err = issues_model.Issues(issuesOpt); err != nil {
if issues, err = issues_model.Issues(ctx, issuesOpt); err != nil {
ctx.Error(http.StatusInternalServerError, "Issues", err)
return
}
@@ -485,7 +485,7 @@ func ListIssues(ctx *context.APIContext) {
issuesOpt.ListOptions = db.ListOptions{
Page: -1,
}
if filteredCount, err = issues_model.CountIssues(issuesOpt); err != nil {
if filteredCount, err = issues_model.CountIssues(ctx, issuesOpt); err != nil {
ctx.Error(http.StatusInternalServerError, "CountIssues", err)
return
}
@@ -493,7 +493,7 @@ func ListIssues(ctx *context.APIContext) {
ctx.SetLinkHeader(int(filteredCount), listOptions.PageSize)
ctx.SetTotalCountHeader(filteredCount)
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(issues))
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
}
func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
@@ -555,7 +555,7 @@ func GetIssue(ctx *context.APIContext) {
}
return
}
ctx.JSON(http.StatusOK, convert.ToAPIIssue(issue))
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, issue))
}
// CreateIssue create an issue of a repository
@@ -612,7 +612,7 @@ func CreateIssue(ctx *context.APIContext) {
var err error
if ctx.Repo.CanWrite(unit.TypeIssues) {
issue.MilestoneID = form.Milestone
assigneeIDs, err = issues_model.MakeIDsFromAPIAssigneesToAdd(form.Assignee, form.Assignees)
assigneeIDs, err = issues_model.MakeIDsFromAPIAssigneesToAdd(ctx, form.Assignee, form.Assignees)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("Assignee does not exist: [name: %s]", err))
@@ -671,7 +671,7 @@ func CreateIssue(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetIssueByID", err)
return
}
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(issue))
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue))
}
// EditIssue modify an issue of a repository
@@ -823,11 +823,11 @@ func EditIssue(ctx *context.APIContext) {
}
if titleChanged {
notification.NotifyIssueChangeTitle(ctx.Doer, issue, oldTitle)
notification.NotifyIssueChangeTitle(ctx, ctx.Doer, issue, oldTitle)
}
if statusChangeComment != nil {
notification.NotifyIssueChangeStatus(ctx.Doer, issue, statusChangeComment, issue.IsClosed)
notification.NotifyIssueChangeStatus(ctx, ctx.Doer, issue, statusChangeComment, issue.IsClosed)
}
// Refetch from database to assign some automatic values
@@ -836,11 +836,11 @@ func EditIssue(ctx *context.APIContext) {
ctx.InternalServerError(err)
return
}
if err = issue.LoadMilestone(); err != nil {
if err = issue.LoadMilestone(ctx); err != nil {
ctx.InternalServerError(err)
return
}
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(issue))
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue))
}
func DeleteIssue(ctx *context.APIContext) {

View File

@@ -91,7 +91,7 @@ func ListIssueComments(ctx *context.APIContext) {
return
}
if err := issues_model.CommentList(comments).LoadPosters(); err != nil {
if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
return
}
@@ -178,7 +178,7 @@ func ListIssueCommentsAndTimeline(ctx *context.APIContext) {
return
}
if err := issues_model.CommentList(comments).LoadPosters(); err != nil {
if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
return
}
@@ -187,7 +187,7 @@ func ListIssueCommentsAndTimeline(ctx *context.APIContext) {
for _, comment := range comments {
if comment.Type != issues_model.CommentTypeCode && isXRefCommentAccessible(ctx, ctx.Doer, comment, issue.RepoID) {
comment.Issue = issue
apiComments = append(apiComments, convert.ToTimelineComment(comment, ctx.Doer))
apiComments = append(apiComments, convert.ToTimelineComment(ctx, comment, ctx.Doer))
}
}
@@ -281,21 +281,21 @@ func ListRepoIssueComments(ctx *context.APIContext) {
return
}
if err = issues_model.CommentList(comments).LoadPosters(); err != nil {
if err = issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
return
}
apiComments := make([]*api.Comment, len(comments))
if err := issues_model.CommentList(comments).LoadIssues(); err != nil {
if err := issues_model.CommentList(comments).LoadIssues(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadIssues", err)
return
}
if err := issues_model.CommentList(comments).LoadPosters(); err != nil {
if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
return
}
if _, err := issues_model.CommentList(comments).Issues().LoadRepositories(); err != nil {
if _, err := issues_model.CommentList(comments).Issues().LoadRepositories(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadRepositories", err)
return
}
@@ -354,7 +354,7 @@ func CreateIssueComment(ctx *context.APIContext) {
return
}
comment, err := comment_service.CreateIssueComment(ctx.Doer, ctx.Repo.Repository, issue, form.Body, nil)
comment, err := comment_service.CreateIssueComment(ctx, ctx.Doer, ctx.Repo.Repository, issue, form.Body, nil)
if err != nil {
ctx.Error(http.StatusInternalServerError, "CreateIssueComment", err)
return
@@ -409,7 +409,7 @@ func GetIssueComment(ctx *context.APIContext) {
return
}
if err = comment.LoadIssue(); err != nil {
if err = comment.LoadIssue(ctx); err != nil {
ctx.InternalServerError(err)
return
}
@@ -423,7 +423,7 @@ func GetIssueComment(ctx *context.APIContext) {
return
}
if err := comment.LoadPoster(); err != nil {
if err := comment.LoadPoster(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "comment.LoadPoster", err)
return
}
@@ -548,7 +548,7 @@ func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption)
oldContent := comment.Content
comment.Content = form.Body
if err := comment_service.UpdateComment(comment, ctx.Doer, oldContent); err != nil {
if err := comment_service.UpdateComment(ctx, comment, ctx.Doer, oldContent); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateComment", err)
return
}
@@ -647,7 +647,7 @@ func deleteIssueComment(ctx *context.APIContext) {
return
}
if err = comment_service.DeleteComment(ctx.Doer, comment); err != nil {
if err = comment_service.DeleteComment(ctx, ctx.Doer, comment); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteCommentByID", err)
return
}

View File

@@ -58,7 +58,7 @@ func GetIssueCommentReactions(ctx *context.APIContext) {
return
}
if err := comment.LoadIssue(); err != nil {
if err := comment.LoadIssue(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "comment.LoadIssue", err)
}
@@ -185,7 +185,7 @@ func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOp
return
}
err = comment.LoadIssue()
err = comment.LoadIssue(ctx)
if err != nil {
ctx.Error(http.StatusInternalServerError, "comment.LoadIssue() failed", err)
}

View File

@@ -139,7 +139,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
}
ctx.SetTotalCountHeader(count)
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(trackedTimes))
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
}
// AddTime add time manual to the given issue
@@ -224,7 +224,7 @@ func AddTime(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}
ctx.JSON(http.StatusOK, convert.ToTrackedTime(trackedTime))
ctx.JSON(http.StatusOK, convert.ToTrackedTime(ctx, trackedTime))
}
// ResetIssueTime reset time manual to the given issue
@@ -448,7 +448,7 @@ func ListTrackedTimesByUser(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(trackedTimes))
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
}
// ListTrackedTimesByRepository lists all tracked times of the repository
@@ -558,7 +558,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
}
ctx.SetTotalCountHeader(count)
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(trackedTimes))
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
}
// ListMyTrackedTimes lists all tracked times of the current user
@@ -620,5 +620,5 @@ func ListMyTrackedTimes(ctx *context.APIContext) {
}
ctx.SetTotalCountHeader(count)
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(trackedTimes))
ctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))
}

View File

@@ -195,7 +195,7 @@ func Migrate(ctx *context.APIContext) {
}
if err == nil {
notification.NotifyMigrateRepository(ctx.Doer, repoOwner, repo)
notification.NotifyMigrateRepository(ctx, ctx.Doer, repoOwner, repo)
return
}

View File

@@ -109,19 +109,19 @@ func ListPullRequests(ctx *context.APIContext) {
apiPrs := make([]*api.PullRequest, len(prs))
for i := range prs {
if err = prs[i].LoadIssue(); err != nil {
if err = prs[i].LoadIssue(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadIssue", err)
return
}
if err = prs[i].LoadAttributes(); err != nil {
if err = prs[i].LoadAttributes(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}
if err = prs[i].LoadBaseRepoCtx(ctx); err != nil {
if err = prs[i].LoadBaseRepo(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadBaseRepo", err)
return
}
if err = prs[i].LoadHeadRepoCtx(ctx); err != nil {
if err = prs[i].LoadHeadRepo(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadHeadRepo", err)
return
}
@@ -173,11 +173,11 @@ func GetPullRequest(ctx *context.APIContext) {
return
}
if err = pr.LoadBaseRepoCtx(ctx); err != nil {
if err = pr.LoadBaseRepo(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadBaseRepo", err)
return
}
if err = pr.LoadHeadRepoCtx(ctx); err != nil {
if err = pr.LoadHeadRepo(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadHeadRepo", err)
return
}
@@ -300,7 +300,7 @@ func CreatePullRequest(ctx *context.APIContext) {
defer headGitRepo.Close()
// Check if another PR exists with the same targets
existingPr, err := issues_model.GetUnmergedPullRequest(headRepo.ID, ctx.Repo.Repository.ID, headBranch, baseBranch, issues_model.PullRequestFlowGithub)
existingPr, err := issues_model.GetUnmergedPullRequest(ctx, headRepo.ID, ctx.Repo.Repository.ID, headBranch, baseBranch, issues_model.PullRequestFlowGithub)
if err != nil {
if !issues_model.IsErrPullRequestNotExist(err) {
ctx.Error(http.StatusInternalServerError, "GetUnmergedPullRequest", err)
@@ -320,7 +320,7 @@ func CreatePullRequest(ctx *context.APIContext) {
}
if len(form.Labels) > 0 {
labels, err := issues_model.GetLabelsInRepoByIDs(ctx.Repo.Repository.ID, form.Labels)
labels, err := issues_model.GetLabelsInRepoByIDs(ctx, ctx.Repo.Repository.ID, form.Labels)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsInRepoByIDs", err)
return
@@ -334,7 +334,7 @@ func CreatePullRequest(ctx *context.APIContext) {
}
if ctx.Repo.Owner.IsOrganization() {
orgLabels, err := issues_model.GetLabelsInOrgByIDs(ctx.Repo.Owner.ID, form.Labels)
orgLabels, err := issues_model.GetLabelsInOrgByIDs(ctx, ctx.Repo.Owner.ID, form.Labels)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsInOrgByIDs", err)
return
@@ -389,7 +389,7 @@ func CreatePullRequest(ctx *context.APIContext) {
}
// Get all assignee IDs
assigneeIDs, err := issues_model.MakeIDsFromAPIAssigneesToAdd(form.Assignee, form.Assignees)
assigneeIDs, err := issues_model.MakeIDsFromAPIAssigneesToAdd(ctx, form.Assignee, form.Assignees)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("Assignee does not exist: [name: %s]", err))
@@ -400,7 +400,7 @@ func CreatePullRequest(ctx *context.APIContext) {
}
// Check if the passed assignees is assignable
for _, aID := range assigneeIDs {
assignee, err := user_model.GetUserByID(aID)
assignee, err := user_model.GetUserByIDCtx(ctx, aID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserByID", err)
return
@@ -483,7 +483,7 @@ func EditPullRequest(ctx *context.APIContext) {
return
}
err = pr.LoadIssue()
err = pr.LoadIssue(ctx)
if err != nil {
ctx.Error(http.StatusInternalServerError, "LoadIssue", err)
return
@@ -551,14 +551,14 @@ func EditPullRequest(ctx *context.APIContext) {
}
if ctx.Repo.CanWrite(unit.TypePullRequests) && form.Labels != nil {
labels, err := issues_model.GetLabelsInRepoByIDs(ctx.Repo.Repository.ID, form.Labels)
labels, err := issues_model.GetLabelsInRepoByIDs(ctx, ctx.Repo.Repository.ID, form.Labels)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsInRepoByIDsError", err)
return
}
if ctx.Repo.Owner.IsOrganization() {
orgLabels, err := issues_model.GetLabelsInOrgByIDs(ctx.Repo.Owner.ID, form.Labels)
orgLabels, err := issues_model.GetLabelsInOrgByIDs(ctx, ctx.Repo.Owner.ID, form.Labels)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsInOrgByIDs", err)
return
@@ -591,11 +591,11 @@ func EditPullRequest(ctx *context.APIContext) {
}
if titleChanged {
notification.NotifyIssueChangeTitle(ctx.Doer, issue, oldTitle)
notification.NotifyIssueChangeTitle(ctx, ctx.Doer, issue, oldTitle)
}
if statusChangeComment != nil {
notification.NotifyIssueChangeStatus(ctx.Doer, issue, statusChangeComment, issue.IsClosed)
notification.NotifyIssueChangeStatus(ctx, ctx.Doer, issue, statusChangeComment, issue.IsClosed)
}
// change pull target branch
@@ -619,7 +619,7 @@ func EditPullRequest(ctx *context.APIContext) {
}
return
}
notification.NotifyPullRequestChangeTargetBranch(ctx.Doer, pr, form.Base)
notification.NotifyPullRequestChangeTargetBranch(ctx, ctx.Doer, pr, form.Base)
}
// update allow edits
@@ -743,12 +743,12 @@ func MergePullRequest(ctx *context.APIContext) {
return
}
if err := pr.LoadHeadRepoCtx(ctx); err != nil {
if err := pr.LoadHeadRepo(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadHeadRepo", err)
return
}
if err := pr.LoadIssueCtx(ctx); err != nil {
if err := pr.LoadIssue(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadIssue", err)
return
}
@@ -811,7 +811,7 @@ func MergePullRequest(ctx *context.APIContext) {
message := strings.TrimSpace(form.MergeTitleField)
if len(message) == 0 {
message, err = pull_service.GetDefaultMergeMessage(ctx.Repo.GitRepo, pr, repo_model.MergeStyle(form.Do))
message, err = pull_service.GetDefaultMergeMessage(ctx, ctx.Repo.GitRepo, pr, repo_model.MergeStyle(form.Do))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetDefaultMergeMessage", err)
return
@@ -1097,7 +1097,7 @@ func UpdatePullRequest(ctx *context.APIContext) {
return
}
if err = pr.LoadIssue(); err != nil {
if err = pr.LoadIssue(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadIssue", err)
return
}
@@ -1107,11 +1107,11 @@ func UpdatePullRequest(ctx *context.APIContext) {
return
}
if err = pr.LoadBaseRepoCtx(ctx); err != nil {
if err = pr.LoadBaseRepo(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadBaseRepo", err)
return
}
if err = pr.LoadHeadRepoCtx(ctx); err != nil {
if err = pr.LoadHeadRepo(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadHeadRepo", err)
return
}
@@ -1267,7 +1267,7 @@ func GetPullRequestCommits(ctx *context.APIContext) {
return
}
if err := pr.LoadBaseRepoCtx(ctx); err != nil {
if err := pr.LoadBaseRepo(ctx); err != nil {
ctx.InternalServerError(err)
return
}
@@ -1383,12 +1383,12 @@ func GetPullRequestFiles(ctx *context.APIContext) {
return
}
if err := pr.LoadBaseRepo(); err != nil {
if err := pr.LoadBaseRepo(ctx); err != nil {
ctx.InternalServerError(err)
return
}
if err := pr.LoadHeadRepo(); err != nil {
if err := pr.LoadHeadRepo(ctx); err != nil {
ctx.InternalServerError(err)
return
}

View File

@@ -71,7 +71,7 @@ func ListPullReviews(ctx *context.APIContext) {
return
}
if err = pr.LoadIssue(); err != nil {
if err = pr.LoadIssue(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadIssue", err)
return
}
@@ -476,7 +476,7 @@ func SubmitPullReview(ctx *context.APIContext) {
// preparePullReviewType return ReviewType and false or nil and true if an error happen
func preparePullReviewType(ctx *context.APIContext, pr *issues_model.PullRequest, event api.ReviewStateType, body string, hasComments bool) (issues_model.ReviewType, bool) {
if err := pr.LoadIssue(); err != nil {
if err := pr.LoadIssue(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadIssue", err)
return -1, true
}

View File

@@ -61,7 +61,7 @@ func GetRelease(ctx *context.APIContext) {
return
}
if err := release.LoadAttributes(); err != nil {
if err := release.LoadAttributes(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}
@@ -123,14 +123,14 @@ func ListReleases(ctx *context.APIContext) {
IsPreRelease: ctx.FormOptionalBool("pre-release"),
}
releases, err := repo_model.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)
releases, err := repo_model.GetReleasesByRepoID(ctx, ctx.Repo.Repository.ID, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetReleasesByRepoID", err)
return
}
rels := make([]*api.Release, len(releases))
for i, release := range releases {
if err := release.LoadAttributes(); err != nil {
if err := release.LoadAttributes(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}
@@ -313,7 +313,7 @@ func EditRelease(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err)
return
}
if err := rel.LoadAttributes(); err != nil {
if err := rel.LoadAttributes(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}

View File

@@ -114,7 +114,7 @@ func ListReleaseAttachments(ctx *context.APIContext) {
ctx.NotFound()
return
}
if err := release.LoadAttributes(); err != nil {
if err := release.LoadAttributes(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}

View File

@@ -60,7 +60,7 @@ func GetReleaseByTag(ctx *context.APIContext) {
return
}
if err = release.LoadAttributes(); err != nil {
if err = release.LoadAttributes(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}

View File

@@ -191,7 +191,7 @@ func Search(ctx *context.APIContext) {
}
var err error
repos, count, err := repo_model.SearchRepository(opts)
repos, count, err := repo_model.SearchRepository(ctx, opts)
if err != nil {
ctx.JSON(http.StatusInternalServerError, api.SearchError{
OK: false,
@@ -209,7 +209,7 @@ func Search(ctx *context.APIContext) {
})
return
}
accessMode, err := access_model.AccessLevel(ctx.Doer, repo)
accessMode, err := access_model.AccessLevel(ctx, ctx.Doer, repo)
if err != nil {
ctx.JSON(http.StatusInternalServerError, api.SearchError{
OK: false,

View File

@@ -86,7 +86,7 @@ func NewWikiPage(ctx *context.APIContext) {
wikiPage := getWikiPage(ctx, wikiName)
if !ctx.Written() {
notification.NotifyNewWikiPage(ctx.Doer, ctx.Repo.Repository, wikiName, form.Message)
notification.NotifyNewWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, wikiName, form.Message)
ctx.JSON(http.StatusCreated, wikiPage)
}
}
@@ -154,7 +154,7 @@ func EditWikiPage(ctx *context.APIContext) {
wikiPage := getWikiPage(ctx, newWikiName)
if !ctx.Written() {
notification.NotifyEditWikiPage(ctx.Doer, ctx.Repo.Repository, newWikiName, form.Message)
notification.NotifyEditWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, newWikiName, form.Message)
ctx.JSON(http.StatusOK, wikiPage)
}
}
@@ -245,7 +245,7 @@ func DeleteWikiPage(ctx *context.APIContext) {
return
}
notification.NotifyDeleteWikiPage(ctx.Doer, ctx.Repo.Repository, wikiName)
notification.NotifyDeleteWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, wikiName)
ctx.Status(http.StatusNoContent)
}