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
ffcbf2bb
Commit
ffcbf2bb
authored
Apr 01, 2013
by
Christos Stavrakakis
Browse files
Create helper function for getting config
parent
0067fdb1
Changes
3
Hide whitespace changes
Inline
Side-by-side
devflow/autopkg.py
View file @
ffcbf2bb
...
...
@@ -161,8 +161,7 @@ def main():
raise
RuntimeError
(
red
(
"Repository %s is dirty."
%
toplevel
))
# Get packages from configuration file
config_file
=
options
.
config_file
or
os
.
path
.
join
(
toplevel
,
"devflow.conf"
)
config
=
ConfigObj
(
config_file
)
config
=
utils
.
get_config
(
options
.
config_file
)
packages
=
config
[
'packages'
].
keys
()
print_green
(
"Will build the following packages:
\n
"
+
"
\n
"
.
join
(
packages
))
...
...
devflow/utils.py
View file @
ffcbf2bb
...
...
@@ -34,20 +34,33 @@
import
os
import
git
from
collections
import
namedtuple
from
configobj
import
ConfigObj
from
devflow
import
BRANCH_TYPES
def
get_repository
():
def
get_repository
(
path
=
None
):
"""Load the repository from the current working dir."""
if
path
is
None
:
path
=
os
.
getcwd
()
try
:
return
git
.
Repo
(
"."
)
return
git
.
Repo
(
path
)
except
git
.
InvalidGitRepositoryError
:
msg
=
"Cound not retrivie git information. Directory '%s'"
\
" is not a git repository!"
%
os
.
getcwd
()
" is not a git repository!"
%
path
raise
RuntimeError
(
msg
)
def
get_config
(
path
=
None
):
"""Load configuration file."""
if
path
is
None
:
toplevel
=
get_vcs_info
().
toplevel
path
=
os
.
path
.
join
(
toplevel
,
"devflow.conf"
)
config
=
ConfigObj
(
path
)
return
config
def
get_vcs_info
():
"""Return current git HEAD commit information.
...
...
devflow/versioning.py
View file @
ffcbf2bb
...
...
@@ -47,7 +47,6 @@ import sys
import
pprint
from
distutils
import
log
# pylint: disable=E0611
from
configobj
import
ConfigObj
from
devflow
import
BRANCH_TYPES
,
BASE_VERSION_FILE
from
devflow
import
utils
...
...
@@ -370,9 +369,9 @@ def update_version():
"""
v
=
utils
.
get_vcs_info
()
toplevel
=
v
.
toplevel
+
"/"
toplevel
=
v
.
toplevel
config
=
ConfigObj
(
toplevel
+
"devflow.
conf
"
)
config
=
utils
.
get_
conf
ig
(
)
if
not
v
:
# Return early if not in development environment
raise
RuntimeError
(
"Can not compute version outside of a git"
...
...
@@ -392,8 +391,9 @@ __version_user_info__ = "%(user_info)s"
for
_pkg_name
,
pkg_info
in
config
[
'packages'
].
items
():
version_filename
=
pkg_info
[
'version_file'
]
if
version_filename
:
path
=
os
.
path
.
join
(
toplevel
,
version_filename
)
log
.
info
(
"Updating version file '%s'"
%
version_filename
)
version_file
=
file
(
toplevel
+
version_filename
,
"w+"
)
version_file
=
file
(
path
,
"w+"
)
version_file
.
write
(
content
)
version_file
.
close
()
...
...
@@ -421,7 +421,7 @@ def bump_version(new_version):
old_version
=
get_base_version
(
v
)
sys
.
stdout
.
write
(
"Current base version is '%s'
\n
"
%
old_version
)
version_file
=
toplevel
+
"
/
version"
version_file
=
os
.
path
.
join
(
toplevel
,
"version"
)
sys
.
stdout
.
write
(
"Updating version file %s from version '%s' to '%s'
\n
"
%
(
version_file
,
old_version
,
new_version
))
...
...
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