From: Holger Levsen Date: Wed, 8 Feb 2012 18:04:06 +0000 (+0100) Subject: lets try to get rid of the double clone X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=ed3200cd69b0422d32a70095f5aa46f2fa574556;p=profitbricks%2Fjenkins-build-scripts.git lets try to get rid of the double clone --- diff --git a/debian_build.py b/debian_build.py index cf7bf39..66b97bd 100755 --- a/debian_build.py +++ b/debian_build.py @@ -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, diff --git a/lib/git_helper.py b/lib/git_helper.py index 228f63a..ae03728 100644 --- a/lib/git_helper.py +++ b/lib/git_helper.py @@ -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,