]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Optionally, don't remove a repo when errors occur
authorZack Cerza <zack@cerza.org>
Thu, 3 Jul 2014 00:26:52 +0000 (18:26 -0600)
committerZack Cerza <zack@cerza.org>
Thu, 3 Jul 2014 00:26:52 +0000 (18:26 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/repo_utils.py

index bf5a28cbbb97d380e81c16837f2deb89bce92fd8..6538f0d371cdd25014f7d6cd1a39ef12519be712 100644 (file)
@@ -7,7 +7,7 @@ import time
 log = logging.getLogger(__name__)
 
 
-def enforce_repo_state(repo_url, dest_path, branch):
+def enforce_repo_state(repo_url, dest_path, branch, remove_on_error=True):
     """
     Use git to either clone or update a given repo, forcing it to switch to the
     specified branch.
@@ -15,6 +15,7 @@ def enforce_repo_state(repo_url, dest_path, branch):
     :param repo_url:  The full URL to the repo (not including the branch)
     :param dest_path: The full path to the destination directory
     :param branch:    The branch.
+    :param remove:    Whether or not to remove dest_dir when an error occurs
     :raises:          BranchNotFoundError if the branch is not found;
                       RuntimeError for other errors
     """
@@ -33,7 +34,8 @@ def enforce_repo_state(repo_url, dest_path, branch):
 
         reset_repo(repo_url, dest_path, branch)
     except BranchNotFoundError:
-        shutil.rmtree(dest_path, ignore_errors=True)
+        if remove_on_error:
+            shutil.rmtree(dest_path, ignore_errors=True)
         raise