Commit d0c4fc17 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Get debian branches from origin

Try to get "debian-*" branches from origin, before falling
back to debian branch.
parent e87745ef
......@@ -176,16 +176,9 @@ def main():
raise ValueError("Malformed branch name '%s', cannot classify as"
" one of %s" % (branch, allowed_branches))
# Check that original repo has the correct debian branch
debian_branch = "debian-" + branch
# Get the debian branch
debian_branch = utils.get_debian_branch(branch)
origin_debian = "origin/" + debian_branch
if not debian_branch in original_repo.branches:
# Get default debian branch
default_debian = BRANCH_TYPES[branch_type_str].default_debian_branch
origin_debian = "origin/" + default_debian
if not default_debian in original_repo.branches:
# Clone the repo
repo_dir = options.repo_dir or create_temp_directory("df-repo")
......@@ -94,3 +94,27 @@ def get_commit_id(commit, current_branch):
return short_id(commit)
raise RuntimeError("Commit %s has more than 2 parents!" % commit)
def get_debian_branch(branch):
"""Find the corresponding debian- branch"""
if branch == "master":
return "debian"
# Check if debian-branch exists (local or origin)
deb_branch = "debian-" + branch
if _get_branch(deb_branch) or _get_branch("origin/" + deb_branch):
return deb_branch
return "debian"
def _get_branch(branch):
repo = get_repository()
if branch in repo.branches:
return branch
origin_branch = "origin/" + branch
if origin_branch in repo.refs:
print "Creating branch '%s' to track '%s'" (branch, origin_branch)
repo.git.branch(branch, origin_branch)
return branch
return None
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment