diff options
author | zeripath <art27@cantab.net> | 2019-11-13 18:51:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-13 18:51:33 +0000 |
commit | fb5af37b3e1a29eff15281d76cada6ab3fb04974 (patch) | |
tree | 3653cbf7122ca7ddfe8612687295a940669a9c36 /modules/git/repo_commit_test.go | |
parent | 2ef37522b6c8b1ae05f07755718751744162908a (diff) | |
download | gitea-fb5af37b3e1a29eff15281d76cada6ab3fb04974.tar.gz gitea-fb5af37b3e1a29eff15281d76cada6ab3fb04974.zip |
Add Close() method to gogitRepository (#8901) (#8958)
Backport #8901 - Adjusted slightly for 1.9
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
Diffstat (limited to 'modules/git/repo_commit_test.go')
-rw-r--r-- | modules/git/repo_commit_test.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/git/repo_commit_test.go b/modules/git/repo_commit_test.go index c59e143cc3..82aa0a0f3c 100644 --- a/modules/git/repo_commit_test.go +++ b/modules/git/repo_commit_test.go @@ -15,6 +15,7 @@ func TestRepository_GetCommitBranches(t *testing.T) { bareRepo1Path := filepath.Join(testReposDir, "repo1_bare") bareRepo1, err := OpenRepository(bareRepo1Path) assert.NoError(t, err) + defer bareRepo1.Close() // these test case are specific to the repo1_bare test repo testCases := []struct { @@ -40,6 +41,9 @@ func TestRepository_GetCommitBranches(t *testing.T) { func TestGetTagCommitWithSignature(t *testing.T) { bareRepo1Path := filepath.Join(testReposDir, "repo1_bare") bareRepo1, err := OpenRepository(bareRepo1Path) + assert.NoError(t, err) + defer bareRepo1.Close() + commit, err := bareRepo1.GetCommit("3ad28a9149a2864384548f3d17ed7f38014c9e8a") assert.NoError(t, err) @@ -52,6 +56,9 @@ func TestGetTagCommitWithSignature(t *testing.T) { func TestGetCommitWithBadCommitID(t *testing.T) { bareRepo1Path := filepath.Join(testReposDir, "repo1_bare") bareRepo1, err := OpenRepository(bareRepo1Path) + assert.NoError(t, err) + defer bareRepo1.Close() + commit, err := bareRepo1.GetCommit("bad_branch") assert.Nil(t, commit) assert.Error(t, err) |