mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-02 17:59:29 +00:00
refactor: use WithRepo instead of WithDir for most git operations, clean up model migrations (#38555)
by the way, remove some unnecessary "models" imports from model migration package, fix migration test model init bug (modelmigration/migrationtest/tests.go)
This commit is contained in:
@@ -6,8 +6,10 @@ package git
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"gitea.dev/modules/git/gitcmd"
|
||||
"gitea.dev/modules/util"
|
||||
)
|
||||
|
||||
type BufferedReader interface {
|
||||
@@ -49,8 +51,11 @@ type CatFileBatchCloser interface {
|
||||
// The CatFileBatch and the readers create by it should only be used in the same goroutine.
|
||||
func NewBatch(ctx context.Context, repo RepositoryFacade) (CatFileBatchCloser, error) {
|
||||
repoPath := gitcmd.RepoLocalPath(repo)
|
||||
if DefaultFeatures().SupportCatFileBatchCommand {
|
||||
return newCatFileBatchCommand(ctx, repoPath)
|
||||
if _, err := os.Stat(repoPath); err != nil {
|
||||
return nil, util.NewNotExistErrorf("repo %q doesn't exist", repo.LogString())
|
||||
}
|
||||
return newCatFileBatchLegacy(ctx, repoPath)
|
||||
if DefaultFeatures().SupportCatFileBatchCommand {
|
||||
return newCatFileBatchCommand(ctx, repo), nil
|
||||
}
|
||||
return newCatFileBatchLegacy(ctx, repo), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user