added commit date in xonfig

This commit is contained in:
Hugo Wang 2016-11-02 12:24:43 +08:00
parent f78a0e1490
commit 53d1d46838
4 changed files with 37 additions and 8 deletions

View file

@ -0,0 +1,14 @@
**Added:** None
* xonfig now contains the latest git commit date if xonsh installed
from source.
**Changed:** None
**Deprecated:** None
**Removed:** None
**Fixed:** None
**Security:** None

View file

@ -129,8 +129,17 @@ def dirty_version():
return False
sha = sha.strip('g')
replace_version(N)
_cmd = ['git', 'show', '--format=%cd', '--date=local', sha]
try:
_date = subprocess.check_output(_cmd)
_date = _date.decode('ascii')
# remove weekday name for a shorter string
_date = ' '.join(_date.split()[1:])
except:
_date = ''
print('failed to get commit date', file=sys.stderr)
with open('xonsh/dev.githash', 'w') as f:
f.write(sha)
f.write('{}|{}'.format(sha, _date))
print('wrote git version: ' + sha, file=sys.stderr)
return True

View file

@ -173,14 +173,14 @@ def pathbasename(p):
@functools.lru_cache(1)
def githash():
install_base = os.path.dirname(__file__)
sha = None
date_ = None
try:
with open('{}/dev.githash'.format(install_base), 'r') as f:
sha = f.read().strip()
if not sha:
sha = None
sha, date_ = f.read().strip().split('|')
except FileNotFoundError:
sha = None
return sha
pass
return sha, date_
#

View file

@ -345,7 +345,12 @@ def _info(ns):
ply.__version__ = '3.8'
data = [
('xonsh', XONSH_VERSION),
('Git SHA', githash()),
]
hash_, date_ = githash()
if hash_:
data.append(('Git SHA', hash_))
data.append(('Commit Date', date_))
data.extend([
('Python', '{}.{}.{}'.format(*PYTHON_VERSION_INFO)),
('PLY', ply.__version__),
('have readline', is_readline_available()),
@ -353,7 +358,8 @@ def _info(ns):
('shell type', env.get('SHELL_TYPE')),
('pygments', pygments_version()),
('on posix', bool(ON_POSIX)),
('on linux', ON_LINUX)]
('on linux', ON_LINUX),
])
if ON_LINUX:
data.append(('distro', linux_distro()))
data.extend([