aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/repo_base_nogogit.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/repo_base_nogogit.go')
-rw-r--r--modules/git/repo_base_nogogit.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/modules/git/repo_base_nogogit.go b/modules/git/repo_base_nogogit.go
index 22c4dfdcb3..14a6cacb44 100644
--- a/modules/git/repo_base_nogogit.go
+++ b/modules/git/repo_base_nogogit.go
@@ -32,10 +32,17 @@ type Repository struct {
checkCancel context.CancelFunc
checkReader *bufio.Reader
checkWriter WriteCloserError
+
+ Ctx context.Context
}
// OpenRepository opens the repository at the given path.
func OpenRepository(repoPath string) (*Repository, error) {
+ return OpenRepositoryCtx(DefaultContext, repoPath)
+}
+
+// OpenRepositoryCtx opens the repository at the given path with the provided context.
+func OpenRepositoryCtx(ctx context.Context, repoPath string) (*Repository, error) {
repoPath, err := filepath.Abs(repoPath)
if err != nil {
return nil, err
@@ -46,28 +53,29 @@ func OpenRepository(repoPath string) (*Repository, error) {
repo := &Repository{
Path: repoPath,
tagCache: newObjectCache(),
+ Ctx: ctx,
}
- repo.batchWriter, repo.batchReader, repo.batchCancel = CatFileBatch(repoPath)
- repo.checkWriter, repo.checkReader, repo.checkCancel = CatFileBatchCheck(repo.Path)
+ repo.batchWriter, repo.batchReader, repo.batchCancel = CatFileBatch(ctx, repoPath)
+ repo.checkWriter, repo.checkReader, repo.checkCancel = CatFileBatchCheck(ctx, repo.Path)
return repo, nil
}
// CatFileBatch obtains a CatFileBatch for this repository
-func (repo *Repository) CatFileBatch() (WriteCloserError, *bufio.Reader, func()) {
+func (repo *Repository) CatFileBatch(ctx context.Context) (WriteCloserError, *bufio.Reader, func()) {
if repo.batchCancel == nil || repo.batchReader.Buffered() > 0 {
log.Debug("Opening temporary cat file batch for: %s", repo.Path)
- return CatFileBatch(repo.Path)
+ return CatFileBatch(ctx, repo.Path)
}
return repo.batchWriter, repo.batchReader, func() {}
}
// CatFileBatchCheck obtains a CatFileBatchCheck for this repository
-func (repo *Repository) CatFileBatchCheck() (WriteCloserError, *bufio.Reader, func()) {
+func (repo *Repository) CatFileBatchCheck(ctx context.Context) (WriteCloserError, *bufio.Reader, func()) {
if repo.checkCancel == nil || repo.checkReader.Buffered() > 0 {
log.Debug("Opening temporary cat file batch-check: %s", repo.Path)
- return CatFileBatchCheck(repo.Path)
+ return CatFileBatchCheck(ctx, repo.Path)
}
return repo.checkWriter, repo.checkReader, func() {}
}