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:
zeripath 2022-01-19 23:26:57 +00:00 committed by GitHub
parent 4563148a61
commit 5cb0c9aa0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
193 changed files with 1264 additions and 1154 deletions

View file

@ -263,7 +263,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
}
}
commitStatus, err := pull_service.GetIssuesLastCommitStatus(issues)
commitStatus, err := pull_service.GetIssuesLastCommitStatus(ctx, issues)
if err != nil {
ctx.ServerError("GetIssuesLastCommitStatus", err)
return
@ -1434,14 +1434,14 @@ func ViewIssue(ctx *context.Context) {
if comment.Review == nil {
continue
}
if err = comment.Review.LoadAttributes(); err != nil {
if err = comment.Review.LoadAttributes(ctx); err != nil {
if !user_model.IsErrUserNotExist(err) {
ctx.ServerError("Review.LoadAttributes", err)
return
}
comment.Review.Reviewer = user_model.NewGhostUser()
}
if err = comment.Review.LoadCodeComments(); err != nil {
if err = comment.Review.LoadCodeComments(ctx); err != nil {
ctx.ServerError("Review.LoadCodeComments", err)
return
}
@ -1471,7 +1471,7 @@ func ViewIssue(ctx *context.Context) {
}
} else if comment.Type == models.CommentTypePullPush {
participants = addParticipant(comment.Poster, participants)
if err = comment.LoadPushCommits(); err != nil {
if err = comment.LoadPushCommits(ctx); err != nil {
ctx.ServerError("LoadPushCommits", err)
return
}
@ -1583,7 +1583,7 @@ func ViewIssue(ctx *context.Context) {
}
ctx.Data["WillSign"] = false
if ctx.User != nil {
sign, key, _, err := asymkey_service.SignMerge(pull, ctx.User, pull.BaseRepo.RepoPath(), pull.BaseBranch, pull.GetGitRefName())
sign, key, _, err := asymkey_service.SignMerge(ctx, pull, ctx.User, pull.BaseRepo.RepoPath(), pull.BaseBranch, pull.GetGitRefName())
ctx.Data["WillSign"] = sign
ctx.Data["SigningKey"] = key
if err != nil {