mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-02 13:44:16 +09:00
refactor(git): replace git stderr matching with exit codes (#39866)
Matching git's stderr text is fragile because it breaks silently when git rewords a message. Where git offers an exit code or a query with a defined answer, use that instead, and drop matches that could never trigger. Follow-up to the discussion in https://github.com/go-gitea/gitea/pull/39857. - Detect a missing remote by `git remote` exit code 2 - Resolve annotated tags to their tree with cat-file `^{tree}` instead of spawning `ls-tree` when listing tree entries - Skip the wiki page lookup when the default branch doesn't exist yet - Remove unreachable "no merge base" and "unknown revision" checks
This commit is contained in:
1 parent
52eb515751
commit
738ff1d65a
12 files changed
+57
-92
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSubTree_Issue29101(t *testing.T) {
|
||||
@@ -26,6 +27,24 @@ func TestSubTree_Issue29101(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTreeListEntriesResolvesTagAndRejectsBlob(t *testing.T) {
|
||||
repo, err := OpenRepositoryLocal(t.Context(), filepath.Join(testReposDir, "repo1_bare"))
|
||||
require.NoError(t, err)
|
||||
defer repo.Close()
|
||||
|
||||
entries, err := newTree(MustIDFromString("3ad28a9149a2864384548f3d17ed7f38014c9e8a")).ListEntries(t.Context(), repo)
|
||||
require.NoError(t, err)
|
||||
names := make([]string, 0, len(entries))
|
||||
for _, entry := range entries {
|
||||
names = append(names, entry.Name())
|
||||
}
|
||||
assert.Equal(t, []string{"file1.txt", "file2.txt", "foo"}, names)
|
||||
assert.True(t, entries[2].IsDir())
|
||||
|
||||
_, err = newTree(MustIDFromString("e2129701f1a4d54dc44f03c93bca0a2aec7c5449")).ListEntries(t.Context(), repo)
|
||||
assert.True(t, IsErrNotExist(err))
|
||||
}
|
||||
|
||||
func Test_GetTreePathLatestCommit(t *testing.T) {
|
||||
repo, err := OpenRepositoryLocal(t.Context(), filepath.Join(testReposDir, "repo6_blame"))
|
||||
assert.NoError(t, err)
|
||||
|
||||
Reference in new issue
Block a user