Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
devflow
Commits
4f36685f
Commit
4f36685f
authored
Apr 02, 2013
by
Christos Stavrakakis
Browse files
Fix bug
Get the type and not the name of the branch to check for correct branch name.
parent
0b8922ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
devflow/autopkg.py
View file @
4f36685f
...
...
@@ -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
())
...
...
devflow/utils.py
View file @
4f36685f
...
...
@@ -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
devflow/versioning.py
View file @
4f36685f
...
...
@@ -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
(
br
norm
)
brnorm
=
utils
.
normalize_branch_name
(
branch
)
btypestr
=
utils
.
get_branch_type
(
br
anch
)
try
:
btype
=
BRANCH_TYPES
[
btypestr
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment