◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
14 changes: 14 additions & 0 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import os.path as osp

from .fun import rev_parse, is_git_dir, find_submodule_git_dir, touch


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -177,9 +179,21 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
args.append(self.git)
self.odb = odbt(*args)

def __del__(self):
if self.git:
self.git.clear_cache()

def __eq__(self, rhs):
if isinstance(rhs, Repo):
Expand Down
16 changes: 10 additions & 6 deletions git/test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@

import contextlib
from functools import wraps
import sys
import io
import logging
import os
import tempfile
import textwrap
import time

from git.compat import string_types, is_win
from git.util import rmtree, cwd

import os.path as osp
if sys.version_info[0:2] == (2, 6):
import unittest2 as unittest
else:
Expand Down @@ -96,7 +100,6 @@ def wrapper(self):
# a windows-only issue. In fact things should be deleted, as well as
# memory maps closed, once objects go out of scope. For some reason
# though this is not the case here unless we collect explicitly.
import gc
gc.collect()
if not keep:
rmtree(path)
Expand Down Expand Up @@ -144,9 +147,10 @@ def repo_creator(self):
os.chdir(prev_cwd)
rw_repo.git.clear_cache()
rw_repo = None
import gc
gc.collect()
if repo_dir is not None:
rmtree(repo_dir)
# END rm test repo if possible
# END cleanup
Expand Down Expand Up @@ -303,7 +307,8 @@ def remote_repo_creator(self):
rw_daemon_repo.git.clear_cache()
del rw_repo
del rw_daemon_repo
import gc
gc.collect()
if rw_repo_dir:
rmtree(rw_repo_dir)
Expand Down Expand Up @@ -357,7 +362,6 @@ def setUpClass(cls):
each test type has its own repository
"""
from git import Repo
import gc
gc.collect()
cls.rorepo = Repo(GIT_REPO)

Expand Down
Toggle all file notes Toggle all file annotations