mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-01 10:40:38 +00:00
refactor: git repo and relative path handling (#38522)
1. simplify "StorageRepo" code 2. simplify git.OpenRepository code 3. by the way, clean up some unused files in git test fixtures.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"gitea.dev/modules/git/gitcmd"
|
||||
"gitea.dev/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -24,9 +25,10 @@ func TestCatFileBatch(t *testing.T) {
|
||||
}
|
||||
|
||||
func testCatFileBatch(t *testing.T) {
|
||||
repo1 := gitcmd.RepositoryUnmanaged(filepath.Join(testReposDir, "repo1_bare"))
|
||||
t.Run("CorruptedGitRepo", func(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
batch, err := NewBatch(t.Context(), tmpDir)
|
||||
batch, err := NewBatch(t.Context(), gitcmd.RepositoryUnmanaged(tmpDir))
|
||||
// as long as the directory exists, no error, because we can't really know whether the git repo is valid until we run commands
|
||||
require.NoError(t, err)
|
||||
defer batch.Close()
|
||||
@@ -47,7 +49,7 @@ func testCatFileBatch(t *testing.T) {
|
||||
assert.ErrorIs(t, err, expectedErr)
|
||||
}
|
||||
|
||||
batch, err := NewBatch(t.Context(), filepath.Join(testReposDir, "repo1_bare"))
|
||||
batch, err := NewBatch(t.Context(), repo1)
|
||||
require.NoError(t, err)
|
||||
defer batch.Close()
|
||||
_, err = batch.QueryInfo("e2129701f1a4d54dc44f03c93bca0a2aec7c5449")
|
||||
@@ -79,7 +81,7 @@ func testCatFileBatch(t *testing.T) {
|
||||
simulateQueryTerminated(t, nil, os.ErrClosed) // pipes are closed faster
|
||||
})
|
||||
|
||||
batch, err := NewBatch(t.Context(), filepath.Join(testReposDir, "repo1_bare"))
|
||||
batch, err := NewBatch(t.Context(), repo1)
|
||||
require.NoError(t, err)
|
||||
defer batch.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user