mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Add Close() method to gogitRepository (#8901)
In investigating #7947 it has become clear that the storage component of go-git repositories needs closing. This PR adds this Close function and adds the Close functions as necessary. In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files. Fixes #7947
This commit is contained in:
@@ -56,6 +56,8 @@ func TestGetContents(t *testing.T) {
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
treePath := "README.md"
|
||||
ref := ctx.Repo.Repository.DefaultBranch
|
||||
|
||||
@@ -82,6 +84,8 @@ func TestGetContentsOrListForDir(t *testing.T) {
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
treePath := "" // root dir
|
||||
ref := ctx.Repo.Repository.DefaultBranch
|
||||
|
||||
@@ -115,6 +119,8 @@ func TestGetContentsOrListForFile(t *testing.T) {
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
treePath := "README.md"
|
||||
ref := ctx.Repo.Repository.DefaultBranch
|
||||
|
||||
@@ -141,6 +147,8 @@ func TestGetContentsErrors(t *testing.T) {
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
treePath := "README.md"
|
||||
ref := repo.DefaultBranch
|
||||
@@ -170,6 +178,8 @@ func TestGetContentsOrListErrors(t *testing.T) {
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
treePath := "README.md"
|
||||
ref := repo.DefaultBranch
|
||||
@@ -198,6 +208,8 @@ func TestGetContentsOrListOfEmptyRepos(t *testing.T) {
|
||||
test.LoadRepo(t, ctx, 15)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
|
||||
t.Run("empty repo", func(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user