From d6c3d8a47552909cb3c085a6206f556d102bf239 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Sun, 26 Jun 2016 11:45:55 -0400 Subject: [PATCH] add minor fixes from review --- setup.py | 11 ++++++----- xonsh/platform.py | 15 ++++++--------- xonsh/xonfig.py | 3 +-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index ba024f8fd..fac35b8f5 100755 --- a/setup.py +++ b/setup.py @@ -112,14 +112,15 @@ def dirty_version(): try: _version = subprocess.check_output(['git', 'describe', '--tags']) _version = _version.decode('ascii') - try: - base, N, sha = _version.strip().split('-') - except ValueError: #on base release - open('xonsh/dev.githash', 'w').close() - return False except subprocess.CalledProcessError: return False + try: + base, N, sha = _version.strip().split('-') + except ValueError: #on base release + open('xonsh/dev.githash', 'w').close() + return False + replace_version(base, N) with open('xonsh/dev.githash', 'w') as f: f.write(sha) diff --git a/xonsh/platform.py b/xonsh/platform.py index 095ad1396..0fdfe8910 100644 --- a/xonsh/platform.py +++ b/xonsh/platform.py @@ -131,18 +131,15 @@ def is_readline_available(): @functools.lru_cache(1) def githash(): - from xonsh import main - install_base = main.__file__.rsplit('/', 1)[0] + install_base = os.path.dirname(__file__) try: with open('{}/dev.githash'.format(install_base), 'r') as f: - hash = f.readlines() - if not hash: - hash = None - else: - hash = hash.pop() + sha = f.read().strip() + if not sha: + sha = None except FileNotFoundError: - hash = None - return hash + sha = None + return sha # diff --git a/xonsh/xonfig.py b/xonsh/xonfig.py index 38c03f2d0..b155cc387 100644 --- a/xonsh/xonfig.py +++ b/xonsh/xonfig.py @@ -352,9 +352,8 @@ def _info(ns): ('on cygwin', ON_CYGWIN), ('is superuser', is_superuser()), ('default encoding', DEFAULT_ENCODING), + ('git SHA', githash()) ]) - if githash(): - data.append(('git SHA', githash())) formatter = _xonfig_format_json if ns.json else _xonfig_format_human s = formatter(data) return s