summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-30 15:57:17 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-30 15:57:17 -0400
commitcd0b996f37a75e212614c23df9020e2022491647 (patch)
tree3dee01a81807c2a576007ab96084653fdb9780ee
parentdf1776a39a8df7e140ae3e62efe4c82895a1e91c (diff)
downloadb4-cd0b996f37a75e212614c23df9020e2022491647.tar.gz
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 <konstantin@linuxfoundation.org>
-rw-r--r--b4/command.py12
1 files changed, 12 insertions, 0 deletions
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()