Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
synnefo
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
synnefo
Commits
c2b51f54
Commit
c2b51f54
authored
13 years ago
by
Kostas Papadimitriou
Browse files
Options
Downloads
Patches
Plain Diff
Fixed version extraction from git describe
Refs #2022
parent
c40c3cf7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
snf-common/Changelog
+2
-0
2 additions, 0 deletions
snf-common/Changelog
snf-common/synnefo/util/version.py
+28
-7
28 additions, 7 deletions
snf-common/synnefo/util/version.py
with
30 additions
and
7 deletions
snf-common/Changelog
+
2
−
0
View file @
c2b51f54
...
@@ -4,6 +4,8 @@ Changelog
...
@@ -4,6 +4,8 @@ Changelog
0.8.0 -> dev
0.8.0 -> dev
------------
------------
* Fixed update_version util to handle namespaced tags (see
get_version_from_describe doctests)
* Skip entry points for python distributions names existing in
* Skip entry points for python distributions names existing in
``SYNNEFO_EXCLUDE_PACKAGES`` environmental variable
``SYNNEFO_EXCLUDE_PACKAGES`` environmental variable
* Avoid duplicate entries in list settings objects
* Avoid duplicate entries in list settings objects
...
...
This diff is collapsed.
Click to expand it.
snf-common/synnefo/util/version.py
+
28
−
7
View file @
c2b51f54
import
pkg_resources
import
pkg_resources
import
os
import
os
import
pprint
import
pprint
import
re
def
get_dist_from_module
(
modname
):
def
get_dist_from_module
(
modname
):
pkgroot
=
pkg_resources
.
get_provider
(
modname
).
egg_root
pkgroot
=
pkg_resources
.
get_provider
(
modname
).
egg_root
...
@@ -38,7 +39,13 @@ def get_component_version(modname):
...
@@ -38,7 +39,13 @@ def get_component_version(modname):
def
vcs_info
():
def
vcs_info
():
"""
"""
Return current git HEAD commit information
Return current git HEAD commit information.
Returns a tuple containing
- branch name
- commit id
- commit index
- git describe output
"""
"""
import
subprocess
import
subprocess
callgit
=
lambda
(
cmd
):
subprocess
.
Popen
(
callgit
=
lambda
(
cmd
):
subprocess
.
Popen
(
...
@@ -54,22 +61,36 @@ def vcs_info():
...
@@ -54,22 +61,36 @@ def vcs_info():
return
branch
,
revid
,
revno
,
desc
return
branch
,
revid
,
revno
,
desc
def
vcs
_version
(
):
def
get
_version
_from_describe
(
describe
):
"""
"""
Package version based on `git describe`
, c
ompatible with setuptools
Package version based on `git describe`
output. C
ompatible with setuptools
version format
version format
>>>
get_version_from_describe
(
"
v0.8.0
"
)
'
0.8.0
'
>>>
get_version_from_describe
(
"
debian/v0.8.0
"
)
'
0.8.0
'
>>>
get_version_from_describe
(
"
0.8.0
"
)
'
0.8.0
'
>>>
get_version_from_describe
(
"
v0.8.0-34-g8f9a1bf
"
)
'
0.8.0-34-g8f9a1bf
'
>>>
get_version_from_describe
(
"
debian/v0.8.0-34-g8f9a1bf
"
)
'
0.8.0-34-g8f9a1bf
'
"""
"""
return
"
-
"
.
join
(
vcs_info
()[
3
].
lstrip
(
'
v
'
).
split
(
"
-
"
)[:
-
1
])
version
=
describe
.
split
(
"
/
"
)[
-
1
].
lstrip
(
'
v
'
)
version
=
version
.
lstrip
(
'
v
'
)
return
version
def
update_version
(
module
,
name
=
'
version
'
,
root
=
"
.
"
):
def
update_version
(
module
,
name
=
'
version
'
,
root
=
"
.
"
):
"""
"""
Helper util to generate/replace a version.py file containing version
Helper util to generate/replace a version.py file containing version
information retrieved from
vcs
_version as a submodule of passed `module`
information retrieved from
get
_version
_from_describe
as a submodule of passed `module`
"""
"""
# exit early if not in development environment
# exit early if not in development environment
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
root
,
'
..
'
,
'
.git
'
)):
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
root
,
'
..
'
,
'
.git
'
))
and
\
not
os
.
path
.
exists
(
os
.
path
.
join
(
root
,
'
.git
'
)):
return
return
paths
=
[
root
]
+
module
.
split
(
"
.
"
)
+
[
"
%s.py
"
%
name
]
paths
=
[
root
]
+
module
.
split
(
"
.
"
)
+
[
"
%s.py
"
%
name
]
...
@@ -78,7 +99,7 @@ def update_version(module, name='version', root="."):
...
@@ -78,7 +99,7 @@ def update_version(module, name='version', root="."):
__version__ =
"
%(version)s
"
__version__ =
"
%(version)s
"
__version_info__ = __version__.split(
"
.
"
)
__version_info__ = __version__.split(
"
.
"
)
__version_vcs_info__ = %(vcs_info)s
__version_vcs_info__ = %(vcs_info)s
"""
%
dict
(
version
=
vcs_version
(
),
"""
%
dict
(
version
=
get_version_from_describe
(
vcs_info
()[
3
]
),
vcs_info
=
pprint
.
PrettyPrinter
().
pformat
(
vcs_info
()))
vcs_info
=
pprint
.
PrettyPrinter
().
pformat
(
vcs_info
()))
module_file
=
file
(
module_filename
,
"
w+
"
)
module_file
=
file
(
module_filename
,
"
w+
"
)
...
...
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