]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
lets try to get rid of the double clone
authorHolger Levsen <holger@layer-acht.org>
Wed, 8 Feb 2012 18:06:13 +0000 (19:06 +0100)
committerHolger Levsen <holger@layer-acht.org>
Wed, 8 Feb 2012 18:06:13 +0000 (19:06 +0100)
lib/git_helper.py

index ae03728db372ba0f2d91f2535725273ecc3069fe..48fa7c9f2d77503b8e26b5ffaddcdea2cf433378 100644 (file)
@@ -72,18 +72,17 @@ def git_clone_remote_repository(url, destination):
 
 def git_new_branch_from(branch_name, from_branch):
     if git_repo_has_branch(branch_name):
-    cmd = [GIT, 'branch', '-D', branch_name]
-
-    cmdobj = subprocess.Popen(
-            cmd,
-            shell=False,
-            close_fds=True,
-            stderr=subprocess.PIPE,
-            stdout=subprocess.PIPE,
-            env={'':''},
-            cwd=os.getcwd()
-    )
-    cmd = [GIT, 'checkout', branch_name]
+        cmd = [GIT, 'branch', '-D', branch_name]
+
+        cmdobj = subprocess.Popen(
+                cmd,
+                shell=False,
+                close_fds=True,
+                stderr=subprocess.PIPE,
+                stdout=subprocess.PIPE,
+                env={'':''},
+                cwd=os.getcwd()
+        )
 
     # this should not happen, we just deleted it
     if git_repo_has_branch(branch_name):
@@ -134,6 +133,7 @@ def git_checkout_branch(branch_name):
     # and there is proper error handling below anyway...
     #if not git_repo_has_branch(branch_name):
     #raise BranchNotExistError(branch_name)
+    cmd = [GIT, 'checkout', branch_name]
 
 
     cmdobj = subprocess.Popen(