Refactor git command stdio pipe (#36393)

And remove the incorrect `ensureValidGitRepository`
This commit is contained in:
wxiaoguang
2026-01-18 02:11:46 +08:00
committed by GitHub
parent 7a2aac406d
commit 149f7a6f1f
9 changed files with 210 additions and 122 deletions

View File

@@ -6,8 +6,11 @@ package git
import (
"context"
"io"
"os"
"path/filepath"
"code.gitea.io/gitea/modules/git/gitcmd"
"code.gitea.io/gitea/modules/util"
)
// catFileBatchLegacy implements the CatFileBatch interface using the "cat-file --batch" command and "cat-file --batch-check" command
@@ -24,8 +27,8 @@ type catFileBatchLegacy struct {
var _ CatFileBatchCloser = (*catFileBatchLegacy)(nil)
func newCatFileBatchLegacy(ctx context.Context, repoPath string) (*catFileBatchLegacy, error) {
if err := ensureValidGitRepository(ctx, repoPath); err != nil {
return nil, err
if _, err := os.Stat(repoPath); err != nil {
return nil, util.NewNotExistErrorf("repo %q doesn't exist", filepath.Base(repoPath))
}
return &catFileBatchLegacy{ctx: ctx, repoPath: repoPath}, nil
}