Skip to content

Commit e2f4663

Browse files
committed
clean up
1 parent 832f5e4 commit e2f4663

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

modules/git/batch.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ import (
88
"context"
99
)
1010

11-
type CatFileBatch interface {
11+
type CatFileBatchQueryContent interface {
1212
QueryContent([]byte) (int, error)
1313
ContentReader() *bufio.Reader
14+
}
15+
16+
type CatFileBatch interface {
17+
CatFileBatchQueryContent
1418

1519
QueryInfo([]byte) (int, error)
1620
InfoReader() *bufio.Reader

modules/git/batch_reader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func (b *catFileBatchCommunicator) Close() {
4545
// This is needed otherwise the git cat-file will hang for invalid repositories.
4646
// FIXME: the comment is from https://github.com/go-gitea/gitea/pull/17991 but it doesn't seem to be true.
4747
// The real problem is that Golang's Cmd.Wait hangs because it waits for the pipes to be closed, but we can't close the pipes before Wait returns
48+
// Need to refactor to use StdinPipe and StdoutPipe
4849
func ensureValidGitRepository(ctx context.Context, repoPath string) error {
4950
stderr := strings.Builder{}
5051
err := gitcmd.NewCommand("rev-parse").

modules/git/repo_commit_nogogit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ func (repo *Repository) getCommit(id ObjectID) (*Commit, error) {
7171

7272
_, _ = batch.QueryContent([]byte(id.String() + "\n"))
7373

74-
return repo.getCommitFromBatchReader(batch, id)
74+
return repo.getCommitFromBatchContentReader(batch, id)
7575
}
7676

77-
func (repo *Repository) getCommitFromBatchReader(batch CatFileBatch, id ObjectID) (*Commit, error) {
77+
func (repo *Repository) getCommitFromBatchContentReader(batch CatFileBatchQueryContent, id ObjectID) (*Commit, error) {
7878
_, typ, size, err := ReadBatchLine(batch.ContentReader())
7979
if err != nil {
8080
if errors.Is(err, io.EOF) || IsErrNotExist(err) {
@@ -106,7 +106,7 @@ func (repo *Repository) getCommitFromBatchReader(batch CatFileBatch, id ObjectID
106106
return nil, err
107107
}
108108

109-
commit, err := repo.getCommitFromBatchReader(batch, tag.Object)
109+
commit, err := repo.getCommitFromBatchContentReader(batch, tag.Object)
110110
if err != nil {
111111
return nil, err
112112
}

modules/git/repo_tree_nogogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (repo *Repository) getTree(id ObjectID) (*Tree, error) {
4141
if _, err := batch.QueryContent([]byte(tag.Object.String() + "\n")); err != nil {
4242
return nil, err
4343
}
44-
commit, err := repo.getCommitFromBatchReader(batch, tag.Object)
44+
commit, err := repo.getCommitFromBatchContentReader(batch, tag.Object)
4545
if err != nil {
4646
return nil, err
4747
}

0 commit comments

Comments
 (0)