mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-28 21:00:03 +02:00
Lazy load object format with command line and don't do it in OpenRepository (#29712)
Most time, when invoking `git.OpenRepository`, `objectFormat` will not be used, so it's a waste to invoke commandline to get the object format. This PR make it a lazy operation, only invoke that when necessary. (cherry picked from commit e84e5db6de0306d514b1f1a9657931fb7197a188)
This commit is contained in:
parent
e825d007b1
commit
c9d9255244
15 changed files with 72 additions and 31 deletions
|
@ -126,17 +126,20 @@ func TestGetCommitFilesChanged(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
defer repo.Close()
|
||||
|
||||
objectFormat, err := repo.GetObjectFormat()
|
||||
assert.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
base, head string
|
||||
files []string
|
||||
}{
|
||||
{
|
||||
repo.objectFormat.EmptyObjectID().String(),
|
||||
objectFormat.EmptyObjectID().String(),
|
||||
"95bb4d39648ee7e325106df01a621c530863a653",
|
||||
[]string{"file1.txt"},
|
||||
},
|
||||
{
|
||||
repo.objectFormat.EmptyObjectID().String(),
|
||||
objectFormat.EmptyObjectID().String(),
|
||||
"8d92fc957a4d7cfd98bc375f0b7bb189a0d6c9f2",
|
||||
[]string{"file2.txt"},
|
||||
},
|
||||
|
@ -146,7 +149,7 @@ func TestGetCommitFilesChanged(t *testing.T) {
|
|||
[]string{"file2.txt"},
|
||||
},
|
||||
{
|
||||
repo.objectFormat.EmptyTree().String(),
|
||||
objectFormat.EmptyTree().String(),
|
||||
"8d92fc957a4d7cfd98bc375f0b7bb189a0d6c9f2",
|
||||
[]string{"file1.txt", "file2.txt"},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue