From cd0b996f37a75e212614c23df9020e2022491647 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 30 Mar 2020 15:57:17 -0400 Subject: Add current rev to version when running from git For ease of tracking version information for folks running things straight out of the checkout, add current git revision to the version info string. Signed-off-by: Konstantin Ryabitsev --- b4/command.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/b4/command.py b/b4/command.py index f36f3ea..d465732 100644 --- a/b4/command.py +++ b/b4/command.py @@ -158,4 +158,16 @@ def cmd(): if __name__ == '__main__': + # We're running from a checkout, so reflect git commit in the version + import os + # noinspection PyBroadException + try: + base = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + dotgit = os.path.join(base, '.git') + ecode, short = b4.git_run_command(dotgit, ['rev-parse', '--short', 'HEAD']) + if ecode == 0: + b4.__VERSION__ = '%s-%s' % (b4.__VERSION__, short.strip()) + except Exception as ex: + # Any failures above are non-fatal + pass cmd() -- cgit v1.2.3