From 258eefa1e7112d9863c95b3e8a1cab5ee50557a2 Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Fri, 30 Oct 2015 23:16:33 +0100 Subject: [PATCH] The clone module can now handle multiple repositories. This is needed to allow gitinspector to be able to clone multiple repositories during the same execution (Needed for #24). --- gitinspector/clone.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gitinspector/clone.py b/gitinspector/clone.py index 667f498..ec68038 100644 --- a/gitinspector/clone.py +++ b/gitinspector/clone.py @@ -23,12 +23,12 @@ import subprocess import sys import tempfile -__cloned_path__ = None +__cloned_paths__ = [] def create(url): if url.startswith("file://") or url.startswith("git://") or url.startswith("http://") or \ url.startswith("https://") or url.startswith("ssh://"): - global __cloned_path__ + global __cloned_paths__ location = tempfile.mkdtemp(suffix=".gitinspector") git_clone = subprocess.Popen(["git", "clone", url, location], bufsize=1, stdout=sys.stderr) @@ -37,10 +37,11 @@ def create(url): if git_clone.returncode != 0: sys.exit(git_clone.returncode) - __cloned_path__ = location + __cloned_paths__.append(location) return location + return url def delete(): - if __cloned_path__: - shutil.rmtree(__cloned_path__, ignore_errors=True) + for path in __cloned_paths__: + shutil.rmtree(path, ignore_errors=True)