Skip to content

Commit fa34fff

Browse files
committed
add context to FindLFSFile
1 parent dbc112d commit fa34fff

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

Diff for: modules/git/pipeline/lfs_gogit.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package pipeline
77

88
import (
99
"bufio"
10+
"context"
1011
"io"
1112
"sort"
1213
"strings"
@@ -20,7 +21,7 @@ import (
2021
)
2122

2223
// FindLFSFile finds commits that contain a provided pointer file hash
23-
func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, error) {
24+
func FindLFSFile(ctx context.Context, repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, error) {
2425
resultsMap := map[string]*LFSResult{}
2526
results := make([]*LFSResult, 0)
2627

@@ -105,7 +106,7 @@ func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, err
105106
i++
106107
}
107108
}()
108-
go NameRevStdin(repo.Ctx, shasToNameReader, nameRevStdinWriter, &wg, basePath)
109+
go NameRevStdin(ctx, shasToNameReader, nameRevStdinWriter, &wg, basePath)
109110
go func() {
110111
defer wg.Done()
111112
defer shasToNameWriter.Close()

Diff for: modules/git/pipeline/lfs_nogogit.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package pipeline
88
import (
99
"bufio"
1010
"bytes"
11+
"context"
1112
"io"
1213
"sort"
1314
"strings"
@@ -17,7 +18,7 @@ import (
1718
)
1819

1920
// FindLFSFile finds commits that contain a provided pointer file hash
20-
func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, error) {
21+
func FindLFSFile(ctx context.Context, repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, error) {
2122
resultsMap := map[string]*LFSResult{}
2223
results := make([]*LFSResult, 0)
2324

@@ -32,7 +33,7 @@ func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, err
3233

3334
go func() {
3435
stderr := strings.Builder{}
35-
err := git.NewCommand("rev-list", "--all").Run(repo.Ctx, &git.RunOpts{
36+
err := git.NewCommand("rev-list", "--all").Run(ctx, &git.RunOpts{
3637
Dir: repo.Path,
3738
Stdout: revListWriter,
3839
Stderr: &stderr,
@@ -46,7 +47,7 @@ func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, err
4647

4748
// Next feed the commits in order into cat-file --batch, followed by their trees and sub trees as necessary.
4849
// so let's create a batch stdin and stdout
49-
batchStdinWriter, batchReader, cancel, err := repo.CatFileBatch(repo.Ctx)
50+
batchStdinWriter, batchReader, cancel, err := repo.CatFileBatch(ctx)
5051
if err != nil {
5152
return nil, err
5253
}
@@ -201,7 +202,7 @@ func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, err
201202
i++
202203
}
203204
}()
204-
go NameRevStdin(repo.Ctx, shasToNameReader, nameRevStdinWriter, &wg, basePath)
205+
go NameRevStdin(ctx, shasToNameReader, nameRevStdinWriter, &wg, basePath)
205206
go func() {
206207
defer wg.Done()
207208
defer shasToNameWriter.Close()

Diff for: routers/web/repo/setting/lfs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ func LFSFileFind(ctx *context.Context) {
407407
ctx.Data["Size"] = size
408408
ctx.Data["SHA"] = sha
409409

410-
results, err := pipeline.FindLFSFile(ctx.Repo.GitRepo, objectID)
410+
results, err := pipeline.FindLFSFile(ctx, ctx.Repo.GitRepo, objectID)
411411
if err != nil && err != io.EOF {
412412
log.Error("Failure in FindLFSFile: %v", err)
413413
ctx.ServerError("LFSFind: FindLFSFile.", err)

0 commit comments

Comments
 (0)