From 8e717d2764030f34aaa10cc098039877c55eaa67 Mon Sep 17 00:00:00 2001 From: GeraldJansen Date: Wed, 20 Nov 2019 12:45:53 +0100 Subject: [PATCH] automatic determination of version string --- src/hamster-lite | 10 ++++++---- src/hamster_lite/lib/runtime.py | 4 +++- wscript | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/hamster-lite b/src/hamster-lite index 9a9e14e..032ed13 100755 --- a/src/hamster-lite +++ b/src/hamster-lite @@ -111,9 +111,6 @@ class HamsterClient(object): def overview(self, *args): self._launch_window("overview") - def statistics(self, *args): - self._launch_window("statistics") - def about(self, *args): self._launch_window("about") @@ -272,6 +269,10 @@ class HamsterClient(object): print() + def version(self): + from hamster.lib.configuration import runtime + print(runtime.version) + if __name__ == '__main__': from hamster_lite.lib import i18n @@ -291,8 +292,9 @@ Actions: * activities: List all the activities names, one per line. * categories: List all the categories names, one per line. - * overview / statistics / about: launch specific window + * overview / add / prefs / about: launch specific window + * version: Show the hamster-lite version Time formats: * 'YYYY-MM-DD hh:mm': If start-date is missing, it will default to today. If end-date is missing, it will default to start-date. diff --git a/src/hamster_lite/lib/runtime.py b/src/hamster_lite/lib/runtime.py index 8729026..3a84159 100644 --- a/src/hamster_lite/lib/runtime.py +++ b/src/hamster_lite/lib/runtime.py @@ -102,7 +102,9 @@ def __init__(self): # if defs is not there, we are running from sources module_dir = os.path.dirname(os.path.realpath(__file__)) self.data_dir = os.path.join(module_dir, '..', '..', '..', 'data') - self.version = "uninstalled" + from subprocess import getstatusoutput + rc, output = getstatusoutput("git describe --tags --always --dirty=+") + self.version = "" if rc else output + " (uninstalled)" self.data_dir = os.path.realpath(self.data_dir) self.storage = db.Storage() diff --git a/wscript b/wscript index afb0b3f..fc8a551 100644 --- a/wscript +++ b/wscript @@ -1,5 +1,7 @@ # -*- python -*- -VERSION = '0.1' +from subprocess import getstatusoutput +rc, output = getstatusoutput("git describe --tags --always --dirty=+") +VERSION = '0.1.0' if rc else output APPNAME = 'hamster-lite' top = '.' out = 'build'