Commit 4450b7e8 authored by Michal Čihař's avatar Michal Čihař

Change version handling

We set -dev version in the sources, what makes handling consistent
regardless whether user runs git or not.

Fixes #921
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 39a86066
...@@ -6,7 +6,7 @@ if [ -z "$1" ] ; then ...@@ -6,7 +6,7 @@ if [ -z "$1" ] ; then
exit 1 exit 1
fi fi
sed -i "s/^VERSION =.*/VERSION = '$1'/" weblate/__init__.py sed -i "s/^VERSION =.*/VERSION = '$1-dev'/" weblate/__init__.py
sed -i "s/version =.*/version = '$1'/" docs/conf.py sed -i "s/version =.*/version = '$1'/" docs/conf.py
sed -i "s/Version: .*/Version: $1/" weblate.spec sed -i "s/Version: .*/Version: $1/" weblate.spec
sed -i "s/version=.*,/version='$1',/" setup.py sed -i "s/version=.*,/version='$1',/" setup.py
......
...@@ -38,44 +38,28 @@ def get_root_dir(): ...@@ -38,44 +38,28 @@ def get_root_dir():
return os.path.abspath(os.path.join(curdir, '..')) return os.path.abspath(os.path.join(curdir, '..'))
def is_running_git():
'''
Checks whether we're running inside Git checkout.
'''
return os.path.exists(os.path.join(get_root_dir(), '.git', 'config'))
# Weblate version # Weblate version
VERSION = '2.5' VERSION = '2.5-dev'
# Version string without suffix # Version string without suffix
VERSION_BASE = VERSION VERSION_BASE = VERSION.replace('-dev', '')
# User-Agent string to use # User-Agent string to use
USER_AGENT = 'Weblate/{0}'.format(VERSION) USER_AGENT = 'Weblate/{0}'.format(VERSION)
# Are we running git
RUNNING_GIT = is_running_git()
GIT_RELEASE = False
GIT_VERSION = VERSION
# Grab some information from git # Grab some information from git
if RUNNING_GIT: try:
try: # Describe current checkout
# Describe current checkout GIT_VERSION = GitRepository(get_root_dir()).describe()
GIT_VERSION = GitRepository(get_root_dir()).describe()
# Check if we're close to release tag
parts = GIT_VERSION.split('-')
GIT_RELEASE = (len(parts) <= 2 or int(parts[2]) < 20)
del parts
# Mark version as devel if it is # Check if we're close to release tag
if not GIT_RELEASE: parts = GIT_VERSION.split('-')
VERSION += '-dev' GIT_RELEASE = (len(parts) <= 2 or int(parts[2]) < 20)
except (RepositoryException, OSError): del parts
# Import failed or git has troubles reading except (RepositoryException, OSError):
# repo (eg. swallow clone) # Import failed or git has troubles reading
RUNNING_GIT = False # repo (eg. swallow clone)
GIT_VERSION = VERSION
def get_doc_url(page, anchor=''): def get_doc_url(page, anchor=''):
...@@ -83,7 +67,7 @@ def get_doc_url(page, anchor=''): ...@@ -83,7 +67,7 @@ def get_doc_url(page, anchor=''):
Return URL to documentation. Return URL to documentation.
''' '''
# Should we use tagged release or latest version # Should we use tagged release or latest version
if RUNNING_GIT and not GIT_RELEASE: if '-dev' in VERSION:
version = 'latest' version = 'latest'
else: else:
version = 'weblate-%s' % VERSION version = 'weblate-%s' % VERSION
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment