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,
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(
#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,