1
0
Fork 0
forked from forgejo/forgejo

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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
148 changed files with 1411 additions and 1564 deletions

View file

@ -67,7 +67,7 @@ func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.
return nil, err
}
notification.NotifyCreateIssueComment(doer, issue.Repo, issue, comment, mentions)
notification.NotifyCreateIssueComment(ctx, doer, issue.Repo, issue, comment, mentions)
return comment, nil
}
@ -119,12 +119,12 @@ var notEnoughLines = regexp.MustCompile(`exit status 128 - fatal: file .* has on
// createCodeComment creates a plain code comment at the specified line / path
func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, issue *issues_model.Issue, content, treePath string, line, reviewID int64) (*issues_model.Comment, error) {
var commitID, patch string
if err := issue.LoadPullRequest(); err != nil {
return nil, fmt.Errorf("GetPullRequestByIssueID: %w", err)
if err := issue.LoadPullRequest(ctx); err != nil {
return nil, fmt.Errorf("LoadPullRequest: %w", err)
}
pr := issue.PullRequest
if err := pr.LoadBaseRepoCtx(ctx); err != nil {
return nil, fmt.Errorf("LoadHeadRepo: %w", err)
if err := pr.LoadBaseRepo(ctx); err != nil {
return nil, fmt.Errorf("LoadBaseRepo: %w", err)
}
gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, pr.BaseRepo.RepoPath())
if err != nil {
@ -254,7 +254,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
return nil, nil, err
}
notification.NotifyPullRequestReview(pr, review, comm, mentions)
notification.NotifyPullRequestReview(ctx, pr, review, comm, mentions)
for _, lines := range review.CodeComments {
for _, comments := range lines {
@ -263,7 +263,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
if err != nil {
return nil, nil, err
}
notification.NotifyPullRequestCodeComment(pr, codeComment, mentions)
notification.NotifyPullRequestCodeComment(ctx, pr, codeComment, mentions)
}
}
}
@ -316,7 +316,7 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string,
return nil, nil
}
if err = review.Issue.LoadPullRequest(); err != nil {
if err = review.Issue.LoadPullRequest(ctx); err != nil {
return
}
if err = review.Issue.LoadAttributes(ctx); err != nil {
@ -339,7 +339,7 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string,
comment.Poster = doer
comment.Issue = review.Issue
notification.NotifyPullRevieweDismiss(doer, review, comment)
notification.NotifyPullReviewDismiss(ctx, doer, review, comment)
return comment, err
}