Skip to content

Commit 8fd4716

Browse files
committed
add context to GetDiffNumChangedFiles
1 parent 3a0af2c commit 8fd4716

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

modules/git/repo_compare.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (repo *Repository) GetCompareInfo(ctx context.Context, basePath, baseBranch
119119
// Count number of changed files.
120120
// This probably should be removed as we need to use shortstat elsewhere
121121
// Now there is git diff --shortstat but this appears to be slower than simply iterating with --nameonly
122-
compareInfo.NumFiles, err = repo.GetDiffNumChangedFiles(remoteBranch, headBranch, directComparison)
122+
compareInfo.NumFiles, err = repo.GetDiffNumChangedFiles(ctx, remoteBranch, headBranch, directComparison)
123123
if err != nil {
124124
return nil, err
125125
}
@@ -139,7 +139,7 @@ func (l *lineCountWriter) Write(p []byte) (n int, err error) {
139139

140140
// GetDiffNumChangedFiles counts the number of changed files
141141
// This is substantially quicker than shortstat but...
142-
func (repo *Repository) GetDiffNumChangedFiles(base, head string, directComparison bool) (int, error) {
142+
func (repo *Repository) GetDiffNumChangedFiles(ctx context.Context, base, head string, directComparison bool) (int, error) {
143143
// Now there is git diff --shortstat but this appears to be slower than simply iterating with --nameonly
144144
w := &lineCountWriter{}
145145
stderr := new(bytes.Buffer)
@@ -151,7 +151,7 @@ func (repo *Repository) GetDiffNumChangedFiles(base, head string, directComparis
151151

152152
// avoid: ambiguous argument 'refs/a...refs/b': unknown revision or path not in the working tree. Use '--': 'git <command> [<revision>...] -- [<file>...]'
153153
if err := NewCommand("diff", "-z", "--name-only").AddDynamicArguments(base+separator+head).AddArguments("--").
154-
Run(repo.Ctx, &RunOpts{
154+
Run(ctx, &RunOpts{
155155
Dir: repo.Path,
156156
Stdout: w,
157157
Stderr: stderr,
@@ -161,7 +161,7 @@ func (repo *Repository) GetDiffNumChangedFiles(base, head string, directComparis
161161
// previously it would return the results of git diff -z --name-only base head so let's try that...
162162
w = &lineCountWriter{}
163163
stderr.Reset()
164-
if err = NewCommand("diff", "-z", "--name-only").AddDynamicArguments(base, head).AddArguments("--").Run(repo.Ctx, &RunOpts{
164+
if err = NewCommand("diff", "-z", "--name-only").AddDynamicArguments(base, head).AddArguments("--").Run(ctx, &RunOpts{
165165
Dir: repo.Path,
166166
Stdout: w,
167167
Stderr: stderr,

routers/api/v1/repo/commits.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ func DownloadCommitDiffOrPatch(ctx *context.APIContext) {
315315
sha := ctx.PathParam("sha")
316316
diffType := git.RawDiffType(ctx.PathParam("diffType"))
317317

318-
if err := git.GetRawDiff(ctx.Repo.GitRepo, sha, diffType, ctx.Resp); err != nil {
318+
if err := git.GetRawDiff(ctx, ctx.Repo.GitRepo, sha, diffType, ctx.Resp); err != nil {
319319
if git.IsErrNotExist(err) {
320320
ctx.APIErrorNotFound(sha)
321321
return

routers/web/repo/cherry_pick.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func CherryPickPost(ctx *context.Context) {
155155
return
156156
}
157157
} else {
158-
if err := git.GetRawDiff(ctx.Repo.GitRepo, sha, git.RawDiffType("patch"), buf); err != nil {
158+
if err := git.GetRawDiff(ctx, ctx.Repo.GitRepo, sha, git.RawDiffType("patch"), buf); err != nil {
159159
if git.IsErrNotExist(err) {
160160
ctx.NotFound(errors.New("commit " + ctx.PathParam("sha") + " does not exist."))
161161
return

routers/web/repo/commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ func RawDiff(ctx *context.Context) {
431431
return
432432
}
433433
}
434-
if err := git.GetRawDiff(
434+
if err := git.GetRawDiff(ctx,
435435
gitRepo,
436436
ctx.PathParam("sha"),
437437
git.RawDiffType(ctx.PathParam("ext")),

0 commit comments

Comments
 (0)