From 9edc595440e6e64467d36d2f0f60ce8eee8450f8 Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 6 Jun 2018 00:07:05 +0200 Subject: Introduce a helper function for versioning The `version_helper` function should make version changes simpler, upon a release simple bump `__version__` and change `__release__` to `True`, afterwards change `__release__` back to `False`. It also tries to call `git describe` so `ranger --version` reports a commit hash if available. This should prevent slip-ups where released versions report ambiguously as being `ranger-master x.y.z` which is what we use for non-release versions. Fixes #1197, which was a misunderstanding caused by a slip-up. --- ranger/__init__.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 -- cgit 1.4.1-2-gfad0 From 536de704bafba18be78007d773d79f31c84c49db Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 6 Jun 2018 00:13:04 +0200 Subject: Update the release checklist about version bumps --- doc/howto-publish-a-release.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit 1.4.1-2-gfad0