Skip to content

Commit e8f1fb3

Browse files
committed
add context to LineBlame
1 parent a4e5604 commit e8f1fb3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

modules/git/repo_blame.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
package git
55

66
import (
7+
"context"
78
"fmt"
89
)
910

1011
// LineBlame returns the latest commit at the given line
11-
func (repo *Repository) LineBlame(revision, path, file string, line uint) (*Commit, error) {
12+
func (repo *Repository) LineBlame(ctx context.Context, revision, path, file string, line uint) (*Commit, error) {
1213
res, _, err := NewCommand("blame").
1314
AddOptionFormat("-L %d,%d", line, line).
1415
AddOptionValues("-p", revision).
15-
AddDashesAndList(file).RunStdString(repo.Ctx, &RunOpts{Dir: path})
16+
AddDashesAndList(file).RunStdString(ctx, &RunOpts{Dir: path})
1617
if err != nil {
1718
return nil, err
1819
}

services/pull/review.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var ErrSubmitReviewOnClosedPR = errors.New("can't submit review for a closed or
5151
// If the line got changed the comment is going to be invalidated.
5252
func checkInvalidation(ctx context.Context, c *issues_model.Comment, repo *git.Repository, branch string) error {
5353
// FIXME differentiate between previous and proposed line
54-
commit, err := repo.LineBlame(branch, repo.Path, c.TreePath, uint(c.UnsignedLine()))
54+
commit, err := repo.LineBlame(ctx, branch, repo.Path, c.TreePath, uint(c.UnsignedLine()))
5555
if err != nil && (strings.Contains(err.Error(), "fatal: no such path") || notEnoughLines.MatchString(err.Error())) {
5656
c.Invalidated = true
5757
return issues_model.UpdateCommentInvalidate(ctx, c)
@@ -233,7 +233,7 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo
233233
// FIXME validate treePath
234234
// Get latest commit referencing the commented line
235235
// No need for get commit for base branch changes
236-
commit, err := gitRepo.LineBlame(head, gitRepo.Path, treePath, uint(line))
236+
commit, err := gitRepo.LineBlame(ctx, head, gitRepo.Path, treePath, uint(line))
237237
if err == nil {
238238
commitID = commit.ID.String()
239239
} else if !(strings.Contains(err.Error(), "exit status 128 - fatal: no such path") || notEnoughLines.MatchString(err.Error())) {

0 commit comments

Comments
 (0)