2024-02-22 04:48:19 +01:00
|
|
|
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package git
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2024-07-30 21:41:10 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
2024-02-22 04:48:19 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSubTree_Issue29101(t *testing.T) {
|
|
|
|
repo, err := openRepositoryWithDefaultContext(filepath.Join(testReposDir, "repo1_bare"))
|
2024-07-30 21:41:10 +02:00
|
|
|
require.NoError(t, err)
|
2024-02-22 04:48:19 +01:00
|
|
|
defer repo.Close()
|
|
|
|
|
|
|
|
commit, err := repo.GetCommit("ce064814f4a0d337b333e646ece456cd39fab612")
|
2024-07-30 21:41:10 +02:00
|
|
|
require.NoError(t, err)
|
2024-02-22 04:48:19 +01:00
|
|
|
|
|
|
|
// old code could produce a different error if called multiple times
|
|
|
|
for i := 0; i < 10; i++ {
|
|
|
|
_, err = commit.SubTree("file1.txt")
|
2024-07-30 21:41:10 +02:00
|
|
|
require.Error(t, err)
|
2024-02-22 04:48:19 +01:00
|
|
|
assert.True(t, IsErrNotExist(err))
|
|
|
|
}
|
|
|
|
}
|