diff options
author | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2018-08-19 16:18:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-19 16:18:41 +0200 |
commit | 5f33450debfdb21477b7a9068c4b8a84ffd6c355 (patch) | |
tree | b027cd879b854df77c04985428593cd1e15a6e26 | |
parent | f4a7ff4d096e0c6283b2c142da6d1806a1fd1615 (diff) | |
parent | 536de704bafba18be78007d773d79f31c84c49db (diff) | |
download | ranger-5f33450debfdb21477b7a9068c4b8a84ffd6c355.tar.gz |
Merge pull request #1198 from toonn/rangerversion
Introduce a helper function for versioning
-rw-r--r-- | doc/howto-publish-a-release.md | 2 | ||||
-rw-r--r-- | ranger/__init__.py | 21 |
2 files changed, 21 insertions, 2 deletions
diff --git a/doc/howto-publish-a-release.md b/doc/howto-publish-a-release.md index 572a2eb7..e8d669ce 100644 --- a/doc/howto-publish-a-release.md +++ b/doc/howto-publish-a-release.md @@ -31,7 +31,7 @@ Test everything Make a release commit --------------------- * [ ] Update the number in the `README` -* [ ] Update `__version__` and `VERSION` in `ranger/__init__.py` +* [ ] Update `__version__` and `__release__` in `ranger/__init__.py` * [ ] Update `__version__` in `ranger/ext/rifle.py` * [ ] `make man` * [ ] Write changelog entry diff --git a/ranger/__init__.py b/ranger/__init__.py index 0d7c8fdc..ae1ecc48 100644 --- a/ranger/__init__.py +++ b/ranger/__init__.py @@ -12,9 +12,28 @@ from __future__ import (absolute_import, division, print_function) import os + +# Version helper +def version_helper(): + if __release__: + version_string = 'ranger {0}'.format(__version__) + else: + import subprocess + version_string = 'ranger-master {0}' + try: + git_describe = subprocess.check_output(['git', 'describe'], + universal_newlines=True, + stderr=subprocess.PIPE) + version_string = version_string.format(git_describe.strip('\n')) + except (OSError, subprocess.CalledProcessError): + version_string = version_string.format(__version__) + return version_string + + # Information __license__ = 'GPL3' __version__ = '1.9.1' +__release__ = False __author__ = __maintainer__ = 'Roman Zimbelmann' __email__ = 'hut@hut.pm' @@ -27,7 +46,7 @@ MACRO_DELIMITER = '%' MACRO_DELIMITER_ESC = '%%' DEFAULT_PAGER = 'less' USAGE = '%prog [options] [path]' -VERSION = 'ranger-master {0}'.format(__version__) +VERSION = version_helper() # These variables are ignored if the corresponding # XDG environment variable is non-empty and absolute |