Skip to content

Commit 3631512

Browse files
committed
add context to GetDiffBinary
1 parent 7dee037 commit 3631512

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

modules/git/repo_compare.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (repo *Repository) GetMergeBase(ctx context.Context, tmpRemote, base, head
5050
}
5151

5252
// GetCompareInfo generates and returns compare information between base and head branches of repositories.
53-
func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string, directComparison, fileOnly bool) (_ *CompareInfo, err error) {
53+
func (repo *Repository) GetCompareInfo(ctx context.Context, basePath, baseBranch, headBranch string, directComparison, fileOnly bool) (_ *CompareInfo, err error) {
5454
var (
5555
remoteBranch string
5656
tmpRemote string
@@ -77,9 +77,9 @@ func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string,
7777
compareInfo.HeadCommitID = headBranch
7878
}
7979

80-
compareInfo.MergeBase, remoteBranch, err = repo.GetMergeBase(tmpRemote, baseBranch, headBranch)
80+
compareInfo.MergeBase, remoteBranch, err = repo.GetMergeBase(ctx, tmpRemote, baseBranch, headBranch)
8181
if err == nil {
82-
compareInfo.BaseCommitID, err = GetFullCommitID(repo.Ctx, repo.Path, remoteBranch)
82+
compareInfo.BaseCommitID, err = GetFullCommitID(ctx, repo.Path, remoteBranch)
8383
if err != nil {
8484
compareInfo.BaseCommitID = remoteBranch
8585
}
@@ -237,8 +237,8 @@ func (repo *Repository) GetDiff(compareArg string, w io.Writer) error {
237237
}
238238

239239
// GetDiffBinary generates and returns patch data between given revisions, including binary diffs.
240-
func (repo *Repository) GetDiffBinary(compareArg string, w io.Writer) error {
241-
return NewCommand("diff", "-p", "--binary", "--histogram").AddDynamicArguments(compareArg).Run(repo.Ctx, &RunOpts{
240+
func (repo *Repository) GetDiffBinary(ctx context.Context, compareArg string, w io.Writer) error {
241+
return NewCommand("diff", "-p", "--binary", "--histogram").AddDynamicArguments(compareArg).Run(ctx, &RunOpts{
242242
Dir: repo.Path,
243243
Stdout: w,
244244
})

services/pull/patch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func DownloadDiffOrPatch(ctx context.Context, pr *issues_model.PullRequest, w io
4646
case patch:
4747
err = gitRepo.GetPatch(compareArg, w)
4848
case binary:
49-
err = gitRepo.GetDiffBinary(compareArg, w)
49+
err = gitRepo.GetDiffBinary(ctx, compareArg, w)
5050
default:
5151
err = gitRepo.GetDiff(compareArg, w)
5252
}
@@ -364,7 +364,7 @@ func checkConflicts(ctx context.Context, pr *issues_model.PullRequest, gitRepo *
364364
_ = util.Remove(tmpPatchFile.Name())
365365
}()
366366

367-
if err := gitRepo.GetDiffBinary(pr.MergeBase+"...tracking", tmpPatchFile); err != nil {
367+
if err := gitRepo.GetDiffBinary(ctx, pr.MergeBase+"...tracking", tmpPatchFile); err != nil {
368368
tmpPatchFile.Close()
369369
log.Error("Unable to get patch file from %s to %s in %s Error: %v", pr.MergeBase, pr.HeadBranch, pr.BaseRepo.FullName(), err)
370370
return false, fmt.Errorf("unable to get patch file from %s to %s in %s Error: %w", pr.MergeBase, pr.HeadBranch, pr.BaseRepo.FullName(), err)

0 commit comments

Comments
 (0)