services/wiki: Close() after error handling (#27129)

Refs: https://codeberg.org/forgejo/forgejo/pulls/1385

Signed-off-by: Lars Lehtonen <lars.lehtonen@gmail.com>
(cherry picked from commit 589e7d346f)

Co-authored-by: Lars Lehtonen <lars.lehtonen@gmail.com>
This commit is contained in:
Earl Warren 2023-09-19 16:45:44 +02:00 committed by GitHub
parent ae8e8f055e
commit f7c64976d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -251,8 +251,8 @@ func TestPrepareWikiFileName(t *testing.T) {
unittest.PrepareTestEnv(t) unittest.PrepareTestEnv(t)
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
gitRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath()) gitRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath())
defer gitRepo.Close()
assert.NoError(t, err) assert.NoError(t, err)
defer gitRepo.Close()
tests := []struct { tests := []struct {
name string name string
@ -303,8 +303,8 @@ func TestPrepareWikiFileName_FirstPage(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
gitRepo, err := git.OpenRepository(git.DefaultContext, tmpDir) gitRepo, err := git.OpenRepository(git.DefaultContext, tmpDir)
defer gitRepo.Close()
assert.NoError(t, err) assert.NoError(t, err)
defer gitRepo.Close()
existence, newWikiPath, err := prepareGitPath(gitRepo, "Home") existence, newWikiPath, err := prepareGitPath(gitRepo, "Home")
assert.False(t, existence) assert.False(t, existence)