Skip to content

Commit 3a0af2c

Browse files
committed
add context to GetRepoRawDiffForFile
1 parent 4f1709b commit 3a0af2c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

modules/git/diff.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const (
2727
)
2828

2929
// GetRawDiff dumps diff results of repository in given commit ID to io.Writer.
30-
func GetRawDiff(repo *Repository, commitID string, diffType RawDiffType, writer io.Writer) error {
31-
return GetRepoRawDiffForFile(repo, "", commitID, diffType, "", writer)
30+
func GetRawDiff(ctx context.Context, repo *Repository, commitID string, diffType RawDiffType, writer io.Writer) error {
31+
return GetRepoRawDiffForFile(ctx, repo, "", commitID, diffType, "", writer)
3232
}
3333

3434
// GetReverseRawDiff dumps the reverse diff results of repository in given commit ID to io.Writer.
@@ -46,7 +46,7 @@ func GetReverseRawDiff(ctx context.Context, repoPath, commitID string, writer io
4646
}
4747

4848
// GetRepoRawDiffForFile dumps diff results of file in given commit ID to io.Writer according given repository
49-
func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diffType RawDiffType, file string, writer io.Writer) error {
49+
func GetRepoRawDiffForFile(ctx context.Context, repo *Repository, startCommit, endCommit string, diffType RawDiffType, file string, writer io.Writer) error {
5050
commit, err := repo.GetCommit(endCommit)
5151
if err != nil {
5252
return err
@@ -89,7 +89,7 @@ func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diff
8989
}
9090

9191
stderr := new(bytes.Buffer)
92-
if err = cmd.Run(repo.Ctx, &RunOpts{
92+
if err = cmd.Run(ctx, &RunOpts{
9393
Dir: repo.Path,
9494
Stdout: writer,
9595
Stderr: stderr,

services/migrations/gitea_uploader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ func (g *GiteaLocalUploader) CreateReviews(ctx context.Context, reviews ...*base
904904
_ = writer.Close()
905905
}()
906906
go func(comment *base.ReviewComment) {
907-
if err := git.GetRepoRawDiffForFile(g.gitRepo, pr.MergeBase, headCommitID, git.RawDiffNormal, comment.TreePath, writer); err != nil {
907+
if err := git.GetRepoRawDiffForFile(ctx, g.gitRepo, pr.MergeBase, headCommitID, git.RawDiffNormal, comment.TreePath, writer); err != nil {
908908
// We should ignore the error since the commit maybe removed when force push to the pull request
909909
log.Warn("GetRepoRawDiffForFile failed when migrating [%s, %s, %s, %s]: %v", g.gitRepo.Path, pr.MergeBase, headCommitID, comment.TreePath, err)
910910
}

services/pull/review.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo
257257
_ = writer.Close()
258258
}()
259259
go func() {
260-
if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, headCommitID, git.RawDiffNormal, treePath, writer); err != nil {
260+
if err := git.GetRepoRawDiffForFile(ctx, gitRepo, pr.MergeBase, headCommitID, git.RawDiffNormal, treePath, writer); err != nil {
261261
_ = writer.CloseWithError(fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %w", gitRepo.Path, pr.MergeBase, headCommitID, treePath, err))
262262
return
263263
}

0 commit comments

Comments
 (0)