Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
devflow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
devflow
Commits
26ada829
Commit
26ada829
authored
11 years ago
by
Filippos Giannakos
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature-fix-release-version' into develop
parents
d1b6f868
37a64ad0
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Changelog
+8
-0
8 additions, 0 deletions
Changelog
devflow/flow.py
+9
-3
9 additions, 3 deletions
devflow/flow.py
devflow/versioning.py
+44
-37
44 additions, 37 deletions
devflow/versioning.py
with
61 additions
and
40 deletions
Changelog
+
8
−
0
View file @
26ada829
#Changelog for feature-fix-release-version
* Fix debian tag when finishing release
* Strip rc from version when ending a release
* Make bump version modular.
* Add a _bump version function without any validation checking. Use the new
validate_version to perform the validation.
* Split version validation from version generating
This diff is collapsed.
Click to expand it.
devflow/flow.py
+
9
−
3
View file @
26ada829
...
@@ -7,7 +7,7 @@ logging.basicConfig()
...
@@ -7,7 +7,7 @@ logging.basicConfig()
from
argparse
import
ArgumentParser
from
argparse
import
ArgumentParser
os
.
environ
[
"
GIT_PYTHON_TRACE
"
]
=
"
full
"
os
.
environ
[
"
GIT_PYTHON_TRACE
"
]
=
"
full
"
from
devflow
import
utils
,
versioning
from
devflow
import
utils
,
versioning
,
RC_RE
from
devflow.version
import
__version__
from
devflow.version
import
__version__
from
devflow.autopkg
import
call
from
devflow.autopkg
import
call
from
devflow.ui
import
query_action
,
query_user
,
query_yes_no
from
devflow.ui
import
query_action
,
query_user
,
query_yes_no
...
@@ -302,11 +302,17 @@ class GitManager(object):
...
@@ -302,11 +302,17 @@ class GitManager(object):
upstream_branch
=
self
.
get_branch
(
"
release
"
,
version
)
upstream_branch
=
self
.
get_branch
(
"
release
"
,
version
)
debian_branch
=
self
.
get_debian_branch
(
"
release
"
,
version
)
debian_branch
=
self
.
get_debian_branch
(
"
release
"
,
version
)
tag
=
upstream_branch
tag
=
upstream_branch
debia
l
_tag
=
"
debian/
"
+
tag
debia
n
_tag
=
"
debian/
"
+
tag
edit_action
=
partial
(
self
.
edit_changelog
,
upstream_branch
,
"
develop
"
)
edit_action
=
partial
(
self
.
edit_changelog
,
upstream_branch
,
"
develop
"
)
self
.
check_edit_changelog
(
edit_action
,
args
,
default
=
True
)
self
.
check_edit_changelog
(
edit_action
,
args
,
default
=
True
)
vcs
=
utils
.
get_vcs_info
()
release_version
=
versioning
.
get_base_version
(
vcs
)
if
re
.
match
(
'
.*
'
+
RC_RE
,
release_version
):
new_version
=
re
.
sub
(
RC_RE
,
''
,
release_version
)
versioning
.
_bump_version
(
new_version
,
vcs
)
#merge to master
#merge to master
self
.
_merge_branches
(
master
,
upstream_branch
)
self
.
_merge_branches
(
master
,
upstream_branch
)
self
.
_merge_branches
(
debian_master
,
debian_branch
)
self
.
_merge_branches
(
debian_master
,
debian_branch
)
...
@@ -315,7 +321,7 @@ class GitManager(object):
...
@@ -315,7 +321,7 @@ class GitManager(object):
repo
.
git
.
checkout
(
master
)
repo
.
git
.
checkout
(
master
)
repo
.
git
.
tag
(
"
%s
"
%
tag
)
repo
.
git
.
tag
(
"
%s
"
%
tag
)
repo
.
git
.
checkout
(
debian
)
repo
.
git
.
checkout
(
debian
)
repo
.
git
.
tag
(
"
%s
"
%
debian
)
repo
.
git
.
tag
(
"
%s
"
%
debian
_tag
)
#merge release changes to upstream
#merge release changes to upstream
self
.
merge_branches
(
upstream
,
upstream_branch
,
args
,
default
=
True
)
self
.
merge_branches
(
upstream
,
upstream_branch
,
args
,
default
=
True
)
...
...
This diff is collapsed.
Click to expand it.
devflow/versioning.py
+
44
−
37
View file @
26ada829
...
@@ -73,6 +73,36 @@ def get_base_version(vcs_info):
...
@@ -73,6 +73,36 @@ def get_base_version(vcs_info):
f
.
close
()
f
.
close
()
return
lines
[
0
]
return
lines
[
0
]
def
validate_version
(
base_version
,
vcs_info
):
branch
=
vcs_info
.
branch
brnorm
=
utils
.
normalize_branch_name
(
branch
)
btypestr
=
utils
.
get_branch_type
(
branch
)
try
:
btype
=
BRANCH_TYPES
[
btypestr
]
except
KeyError
:
allowed_branches
=
"
,
"
.
join
(
x
for
x
in
BRANCH_TYPES
.
keys
())
raise
ValueError
(
"
Malformed branch name
'
%s
'
, cannot classify as one
"
"
of %s
"
%
(
btypestr
,
allowed_branches
))
if
btype
.
versioned
:
try
:
bverstr
=
brnorm
.
split
(
"
-
"
)[
1
]
except
IndexError
:
# No version
raise
ValueError
(
"
Branch name
'
%s
'
should contain version
"
%
branch
)
# Check that version is well-formed
if
not
re
.
match
(
VERSION_RE
,
bverstr
):
raise
ValueError
(
"
Malformed version
'
%s
'
in branch name
'
%s
'"
%
(
bverstr
,
branch
))
m
=
re
.
match
(
btype
.
allowed_version_re
,
base_version
)
if
not
m
or
(
btype
.
versioned
and
m
.
groupdict
()[
"
bverstr
"
]
!=
bverstr
):
raise
ValueError
(
"
Base version
'
%s
'
unsuitable for branch name
'
%s
'"
%
(
base_version
,
branch
))
def
python_version
(
base_version
,
vcs_info
,
mode
):
def
python_version
(
base_version
,
vcs_info
,
mode
):
"""
Generate a Python distribution version following devtools conventions.
"""
Generate a Python distribution version following devtools conventions.
...
@@ -191,36 +221,11 @@ def python_version(base_version, vcs_info, mode):
...
@@ -191,36 +221,11 @@ def python_version(base_version, vcs_info, mode):
"""
"""
validate_version
(
base_version
,
vcs_info
)
branch
=
vcs_info
.
branch
branch
=
vcs_info
.
branch
brnorm
=
utils
.
normalize_branch_name
(
branch
)
btypestr
=
utils
.
get_branch_type
(
branch
)
btypestr
=
utils
.
get_branch_type
(
branch
)
#this cannot fail
try
:
btype
=
BRANCH_TYPES
[
btypestr
]
btype
=
BRANCH_TYPES
[
btypestr
]
except
KeyError
:
allowed_branches
=
"
,
"
.
join
(
x
for
x
in
BRANCH_TYPES
.
keys
())
raise
ValueError
(
"
Malformed branch name
'
%s
'
, cannot classify as one
"
"
of %s
"
%
(
btypestr
,
allowed_branches
))
if
btype
.
versioned
:
try
:
bverstr
=
brnorm
.
split
(
"
-
"
)[
1
]
except
IndexError
:
# No version
raise
ValueError
(
"
Branch name
'
%s
'
should contain version
"
%
branch
)
# Check that version is well-formed
if
not
re
.
match
(
VERSION_RE
,
bverstr
):
raise
ValueError
(
"
Malformed version
'
%s
'
in branch name
'
%s
'"
%
(
bverstr
,
branch
))
m
=
re
.
match
(
btype
.
allowed_version_re
,
base_version
)
if
not
m
or
(
btype
.
versioned
and
m
.
groupdict
()[
"
bverstr
"
]
!=
bverstr
):
raise
ValueError
(
"
Base version
'
%s
'
unsuitable for branch name
'
%s
'"
%
(
base_version
,
branch
))
if
mode
not
in
[
"
snapshot
"
,
"
release
"
]:
if
mode
not
in
[
"
snapshot
"
,
"
release
"
]:
raise
ValueError
(
"
Specified mode
'
%s
'
should be one of
'
snapshot
'
or
"
raise
ValueError
(
"
Specified mode
'
%s
'
should be one of
'
snapshot
'
or
"
...
@@ -407,17 +412,9 @@ def bump_version_main():
...
@@ -407,17 +412,9 @@ def bump_version_main():
sys
.
stdout
.
write
(
"
usage: %s version
\n
"
%
sys
.
argv
[
0
])
sys
.
stdout
.
write
(
"
usage: %s version
\n
"
%
sys
.
argv
[
0
])
def
bump_version
(
new_version
):
def
_bump_version
(
new_version
,
v
):
"""
Set new base version to base version file and commit
"""
v
=
utils
.
get_vcs_info
()
mode
=
utils
.
get_build_mode
()
# Check that new base version is valid
python_version
(
new_version
,
v
,
mode
)
repo
=
utils
.
get_repository
()
repo
=
utils
.
get_repository
()
toplevel
=
repo
.
working_dir
toplevel
=
repo
.
working_dir
old_version
=
get_base_version
(
v
)
old_version
=
get_base_version
(
v
)
sys
.
stdout
.
write
(
"
Current base version is
'
%s
'
\n
"
%
old_version
)
sys
.
stdout
.
write
(
"
Current base version is
'
%s
'
\n
"
%
old_version
)
...
@@ -440,6 +437,16 @@ def bump_version(new_version):
...
@@ -440,6 +437,16 @@ def bump_version(new_version):
sys
.
stdout
.
write
(
"
Update version file and commited
\n
"
)
sys
.
stdout
.
write
(
"
Update version file and commited
\n
"
)
def
bump_version
(
new_version
):
"""
Set new base version to base version file and commit
"""
v
=
utils
.
get_vcs_info
()
# Check that new base version is valid
validate_version
(
new_version
,
v
)
_bump_version
(
new_version
,
v
)
def
main
():
def
main
():
v
=
utils
.
get_vcs_info
()
v
=
utils
.
get_vcs_info
()
b
=
get_base_version
(
v
)
b
=
get_base_version
(
v
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment