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
4a45f70c
Commit
4a45f70c
authored
Feb 05, 2013
by
Christos Stavrakakis
Browse files
pylint fixes
parent
e90c5c7f
Changes
3
Hide whitespace changes
Inline
Side-by-side
devflow/__init__.py
View file @
4a45f70c
"""A set of tools to ease versioning and use of git flow"""
devflow/autopkg.py
View file @
4a45f70c
...
...
@@ -31,12 +31,14 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
"""Helper script for automatic build of debian packages."""
import
git
import
os
import
sys
from
optparse
import
OptionParser
from
collections
import
namedtuple
from
sh
import
mktemp
,
cd
,
rm
,
git_dch
from
sh
import
mktemp
,
cd
,
rm
,
git_dch
# pylint: disable=E0611
from
configobj
import
ConfigObj
from
devflow
import
versioning
...
...
devflow/versioning.py
View file @
4a45f70c
...
...
@@ -33,6 +33,13 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
"""Helper functions for automatic version computation.
This module contains helper functions for extracting information
from a Git repository, and computing the python and debian version
of the repository code.
"""
import
os
import
re
...
...
@@ -90,9 +97,8 @@ def get_commit_id(commit, current_branch):
raise
RuntimeError
(
"Commit %s has more than 2 parents!"
%
commit
)
def
vcs_info
():
"""
Return current git HEAD commit information.
def
get_vcs_info
():
"""Return current git HEAD commit information.
Returns a tuple containing
- branch name
...
...
@@ -120,16 +126,16 @@ def vcs_info():
toplevel
=
toplevel
)
def
base_version
(
vcs_info
):
def
get_
base_version
(
vcs_info
):
"""Determine the base version from a file in the repository"""
f
=
open
(
os
.
path
.
join
(
vcs_info
.
toplevel
,
BASE_VERSION_FILE
))
lines
=
[
l
.
strip
()
for
l
in
f
.
readlines
()]
l
=
[
l
for
l
in
lines
if
not
l
.
startswith
(
"#"
)]
if
len
(
l
)
!=
1
:
l
ines
=
[
l
for
l
in
lines
if
not
l
.
startswith
(
"#"
)]
if
len
(
l
ines
)
!=
1
:
raise
ValueError
(
"File '%s' should contain a single non-comment line."
)
f
.
close
()
return
l
[
0
]
return
l
ines
[
0
]
def
build_mode
():
...
...
@@ -404,8 +410,8 @@ def debian_version_from_python_version(pyver):
def
get_python_version
():
v
=
vcs_info
()
b
=
base_version
(
v
)
v
=
get_
vcs_info
()
b
=
get_
base_version
(
v
)
mode
=
build_mode
()
return
python_version
(
b
,
v
,
mode
)
...
...
@@ -416,8 +422,8 @@ def debian_version(base_version, vcs_info, mode):
def
get_debian_version
():
v
=
vcs_info
()
b
=
base_version
(
v
)
v
=
get_
vcs_info
()
b
=
get_
base_version
(
v
)
mode
=
build_mode
()
return
debian_version
(
b
,
v
,
mode
)
...
...
@@ -429,28 +435,30 @@ def user_info():
def
update_version
():
"""
This is a helper to generate/replace version files containing version
"""Generate or replace version files
Helper function for generating/replacing version files containing version
information.
"""
config
=
ConfigObj
(
"devflow.conf"
)
v
=
vcs_info
()
v
=
get_
vcs_info
()
if
not
v
:
# Return early if not in development environment
raise
RuntimeError
(
"Can not compute version outside of a git"
" repository."
)
b
=
base_version
(
v
)
b
=
get_
base_version
(
v
)
mode
=
build_mode
()
version
=
python_version
(
b
,
v
,
mode
)
vcs_info_dict
=
v
.
_asdict
()
# pylint: disable=W0212
content
=
"""__version__ = "%(version)s"
__version_info__ = %(version_info)s
__version_vcs_info__ = %(vcs_info)s
__version_user_info__ = "%(user_info)s"
"""
%
dict
(
version
=
version
,
version_info
=
version
.
split
(
"."
),
vcs_info
=
pprint
.
PrettyPrinter
().
pformat
(
dict
(
v
.
_as
dict
())
),
vcs_info
=
pprint
.
PrettyPrinter
().
pformat
(
vcs_info_
dict
),
user_info
=
user_info
())
for
_pkg_name
,
pkg_info
in
config
[
'packages'
].
items
():
...
...
@@ -473,7 +481,7 @@ def bump_version_main():
def
bump_version
(
new_version
):
"""Set new base version to base version file and commit"""
v
=
vcs_info
()
v
=
get_
vcs_info
()
mode
=
build_mode
()
# Check that new base version is valid
...
...
@@ -482,7 +490,7 @@ def bump_version(new_version):
repo
=
git
.
Repo
(
"."
)
toplevel
=
repo
.
working_dir
old_version
=
base_version
(
v
)
old_version
=
get_
base_version
(
v
)
sys
.
stdout
.
write
(
"Current base version is '%s'
\n
"
%
old_version
)
version_file
=
toplevel
+
"/version"
...
...
@@ -505,8 +513,8 @@ def bump_version(new_version):
def
main
():
v
=
vcs_info
()
b
=
base_version
(
v
)
v
=
get_
vcs_info
()
b
=
get_
base_version
(
v
)
mode
=
build_mode
()
try
:
...
...
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