]> 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:04:06 +0000 (19:04 +0100)
committerHolger Levsen <holger@layer-acht.org>
Wed, 8 Feb 2012 18:04:06 +0000 (19:04 +0100)
debian_build.py
lib/git_helper.py

index cf7bf399173a5fe59a035ed1eb7e2beeba392642..66b97bddd3a03e074f2911e4b31fd02220af2527 100755 (executable)
@@ -260,12 +260,10 @@ if __name__ == '__main__':
     repo = git.repo.Repo()
 
     #if GIT_BRANCH_NAME != 'master':
-        #git_helper.git_new_branch_from(
-    # FIXME: error checking... (as below)
-    git_helper.git_checkout_branch(
-                GIT_BRANCH_NAME) #,
-        #        os.path.join('origin', GIT_BRANCH_NAME)
-        #)
+    git_helper.git_new_branch_from(
+                GIT_BRANCH_NAME,
+                os.path.join('origin', GIT_BRANCH_NAME)
+        )
 
     # git-buildpackage uses only treeish object in v0.5.10, so let's fetch the 
     # treeish refspec when a name was given (i.e. tag names, branch names, 
index 228f63a3a9e5fd999f7f1d8aecb55c6772842ea1..ae03728db372ba0f2d91f2535725273ecc3069fe 100644 (file)
@@ -71,10 +71,27 @@ def git_clone_remote_repository(url, destination):
     return True
 
 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]
+
+    # this should not happen, we just deleted it
     if git_repo_has_branch(branch_name):
         raise BranchExistError(branch_name)
-#    if not git_repo_has_branch(from_branch):
-#        raise BranchNotExistError(from_branch)
+
+    #if not git_repo_has_branch(from_branch):
+    #    raise BranchNotExistError(from_branch)
+
     cmd = [GIT, 'checkout', '-b', branch_name, from_branch]
 
     cmdobj = subprocess.Popen(
@@ -118,18 +135,6 @@ def git_checkout_branch(branch_name):
     #if not git_repo_has_branch(branch_name):
     #raise BranchNotExistError(branch_name)
 
-    cmd = [GIT, 'reset', '--hard']
-
-    cmdobj = subprocess.Popen(
-            cmd,
-            shell=False,
-            close_fds=True,
-            stderr=subprocess.PIPE,
-            stdout=subprocess.PIPE,
-            env={'':''},
-            cwd=os.getcwd()
-    )
-    cmd = [GIT, 'checkout', branch_name]
 
     cmdobj = subprocess.Popen(
             cmd,