Skip to content

Commit

Permalink
version: do not report 0.x versions when no git repository is present
Browse files Browse the repository at this point in the history
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed May 3, 2024
1 parent 7e1fa42 commit 5d9769b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions cola/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,21 @@ def get(key):
def version():
"""Returns the current version"""
if SCM_VERSION:
pkg_version = SCM_VERSION
else:
pkg_version = VERSION
if metadata is not None:
try:
pkg_version = metadata.version('git-cola')
except (ImportError, OSError):
pass
return SCM_VERSION

pkg_version = VERSION
if metadata is None:
return pkg_version

try:
metadata_version = metadata.version('git-cola')
except (ImportError, OSError):
return pkg_version

# Building from a tarball can end up reporting "0.0.0" or "0.1.dev*".
# Use the fallback version in these scenarios.
if not metadata_version.startswith('0.'):
return metadata_version
return pkg_version


Expand Down

0 comments on commit 5d9769b

Please sign in to comment.