diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-03-12 12:21:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-12 04:21:27 +0000 |
commit | e84e5db6de0306d514b1f1a9657931fb7197a188 (patch) | |
tree | 98baff1bb68b2af272e32b74abaa721523c2e519 /modules/git/blame_test.go | |
parent | 7f856d5d742dcb6febdb8a3f22cd9a8fecc69a4d (diff) | |
download | gitea-e84e5db6de0306d514b1f1a9657931fb7197a188.tar.gz gitea-e84e5db6de0306d514b1f1a9657931fb7197a188.zip |
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.
Diffstat (limited to 'modules/git/blame_test.go')
-rw-r--r-- | modules/git/blame_test.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/git/blame_test.go b/modules/git/blame_test.go index 327edab767..4220c85600 100644 --- a/modules/git/blame_test.go +++ b/modules/git/blame_test.go @@ -118,11 +118,13 @@ func TestReadingBlameOutput(t *testing.T) { }, } + objectFormat, err := repo.GetObjectFormat() + assert.NoError(t, err) for _, c := range cases { commit, err := repo.GetCommit(c.CommitID) assert.NoError(t, err) - blameReader, err := CreateBlameReader(ctx, repo.objectFormat, "./tests/repos/repo6_blame", commit, "blame.txt", c.Bypass) + blameReader, err := CreateBlameReader(ctx, objectFormat, "./tests/repos/repo6_blame", commit, "blame.txt", c.Bypass) assert.NoError(t, err) assert.NotNil(t, blameReader) defer blameReader.Close() |