diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2016-10-01 20:42:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-01 20:42:27 +0200 |
commit | 9d6b417ea3a4507ea78714f0cb7add75b13032d5 (patch) | |
tree | 77365cb808a255eb53889725bfce775b5090330e /git/objects/submodule/base.py | |
parent | 4592785004ad1a4869d650dc35a1e9099245dad9 (diff) | |
parent | 9a521681ff8614beb8e2c566cf3c475baca22169 (diff) | |
download | gitpython-9d6b417ea3a4507ea78714f0cb7add75b13032d5.tar.gz |
Merge pull request #519 from ankostis/appveyor
Test project on Windows with MINGW/Cygwin git (conda2.7&3.4/cpy-3.5)
Diffstat (limited to 'git/objects/submodule/base.py')
-rw-r--r-- | git/objects/submodule/base.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index eea091f8..c6c6d699 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -29,7 +29,8 @@ from git.exc import ( ) from git.compat import ( string_types, - defenc + defenc, + is_win, ) import stat @@ -289,14 +290,16 @@ class Submodule(util.IndexObject, Iterable, Traversable): """ git_file = os.path.join(working_tree_dir, '.git') rela_path = os.path.relpath(module_abspath, start=working_tree_dir) - fp = open(git_file, 'wb') - fp.write(("gitdir: %s" % rela_path).encode(defenc)) - fp.close() + if is_win: + if os.path.isfile(git_file): + os.remove(git_file) + with open(git_file, 'wb') as fp: + fp.write(("gitdir: %s" % rela_path).encode(defenc)) - writer = GitConfigParser(os.path.join(module_abspath, 'config'), read_only=False, merge_includes=False) - writer.set_value('core', 'worktree', - to_native_path_linux(os.path.relpath(working_tree_dir, start=module_abspath))) - writer.release() + with GitConfigParser(os.path.join(module_abspath, 'config'), + read_only=False, merge_includes=False) as writer: + writer.set_value('core', 'worktree', + to_native_path_linux(os.path.relpath(working_tree_dir, start=module_abspath))) #{ Edit Interface @@ -848,13 +851,17 @@ class Submodule(util.IndexObject, Iterable, Traversable): # finally delete our own submodule if not dry_run: + self._clear_cache() wtd = mod.working_tree_dir del(mod) # release file-handles (windows) + import gc + gc.collect() rmtree(wtd) # END delete tree if possible # END handle force if not dry_run and os.path.isdir(git_dir): + self._clear_cache() rmtree(git_dir) # end handle separate bare repository # END handle module deletion |