Commit 4f36685f authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Fix bug

Get the type and not the name of the branch to check for correct
branch name.
parent 0b8922ef
......@@ -166,7 +166,7 @@ def main():
# Get current branch name and type and check if it is a valid one
branch = original_repo.head.reference.name
branch_type_str = versioning.get_branch_type(branch)
branch_type_str = utils.get_branch_type(branch)
if branch_type_str not in BRANCH_TYPES.keys():
allowed_branches = ", ".join(BRANCH_TYPES.keys())
......
......@@ -139,12 +139,33 @@ def get_build_mode():
# Get it from environment if exists
mode = os.environ.get("DEVFLOW_BUILD_MODE", None)
if mode is None:
branch = get_vcs_info().branch
branch = get_branch_type(get_vcs_info().branch)
try:
br_type = BRANCH_TYPES[branch]
br_type = BRANCH_TYPES[get_branch_type(branch)]
except KeyError:
allowed_branches = ", ".join(x for x in BRANCH_TYPES.keys())
raise ValueError("Malformed branch name '%s', cannot classify as"
" one of %s" % (branch, allowed_branches))
mode = "snapshot" if br_type.builds_snapshot else "release"
return mode
def normalize_branch_name(branch_name):
"""Normalize branch name by removing debian- if exists"""
brnorm = branch_name
if brnorm == "debian":
brnorm = "debian-master"
# If it's a debian branch, ignore starting "debian-"
if brnorm.startswith("debian-"):
brnorm = brnorm.replace("debian-", "", 1)
return brnorm
def get_branch_type(branch_name):
"""Extract the type from a branch name"""
branch_name = normalize_branch_name(branch_name)
if "-" in branch_name:
btypestr = branch_name.split("-")[0]
else:
btypestr = branch_name
return btypestr
......@@ -64,26 +64,6 @@ def get_base_version(vcs_info):
return lines[0]
def normalize_branch_name(branch_name):
"""Normalize branch name by removing debian- if exists"""
brnorm = branch_name
if brnorm == "debian":
brnorm = "debian-master"
# If it's a debian branch, ignore starting "debian-"
if brnorm.startswith("debian-"):
brnorm = brnorm.replace("debian-", "", 1)
return brnorm
def get_branch_type(branch_name):
"""Extract the type from a branch name"""
if "-" in branch_name:
btypestr = branch_name.split("-")[0]
else:
btypestr = branch_name
return btypestr
def python_version(base_version, vcs_info, mode):
"""Generate a Python distribution version following devtools conventions.
......@@ -204,8 +184,8 @@ def python_version(base_version, vcs_info, mode):
branch = vcs_info.branch
brnorm = normalize_branch_name(branch)
btypestr = get_branch_type(brnorm)
brnorm = utils.normalize_branch_name(branch)
btypestr = utils.get_branch_type(branch)
try:
btype = BRANCH_TYPES[btypestr]
......
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