Skip to content
Permalink
Browse files

Merge pull request #514 from parkr/topaz-v-git-hash

Add short git revision to 'topaz -v'.
  • Loading branch information
alex committed Mar 17, 2013
2 parents 25e808d + d3c8cf7 commit 2405d6df67296d35b5a219f017281fb4fd4363f2
Showing with 8 additions and 3 deletions.
  1. +4 −1 tests/test_main.py
  2. +4 −2 topaz/main.py
@@ -1,5 +1,6 @@
import os
import platform
import subprocess

import pytest

@@ -64,6 +65,7 @@ def test_verbose(self, space, tmpdir, capfd):
assert "1.9.3" in version
assert os.uname()[4] in version
assert platform.system().lower() in version
assert subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).rstrip() in version
assert out == "5"

self.run(space, tmpdir, ruby_args=["-v"])
@@ -121,6 +123,7 @@ def test_version(self, space, tmpdir, capfd):
assert "1.9.3" in version
assert os.uname()[4] in version
assert platform.system().lower() in version
assert subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).rstrip() in version

def test_stop_consuming_args(self, space, tmpdir, capfd):
self.run(space, tmpdir, ruby_args=["-e", "puts ARGV.join(' ')", "--", "--help", "-e"])
@@ -275,7 +278,7 @@ def test_ruby_description(self, space, tmpdir, capfd):
self.run(space, tmpdir, "puts RUBY_DESCRIPTION")
out1, err1 = capfd.readouterr()
self.run(space, tmpdir, """
puts "#{RUBY_ENGINE} (ruby-#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}) [#{RUBY_PLATFORM}]"
puts "#{RUBY_ENGINE} (ruby-#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}) [#{RUBY_PLATFORM}] (git rev #{RUBY_REVISION})"
""")
out2, err2 = capfd.readouterr()
assert out1 == out2
@@ -1,6 +1,7 @@
from __future__ import absolute_import

import os
import subprocess

from rpython.rlib.objectmodel import specialize
from rpython.rlib.streamio import open_file_as_stream, fdopen_as_stream
@@ -39,7 +40,7 @@
""
])
COPYRIGHT = "topaz - Copyright (c) Alex Gaynor and individual contributors\n"

RUBY_REVISION = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).rstrip()

@specialize.memo()
def getspace():
@@ -188,12 +189,13 @@ def _entry_point(space, argv):
engine = "topaz"
version = "1.9.3"
patchlevel = 125
description = "%s (ruby-%sp%d) [%s]" % (engine, version, patchlevel, platform)
description = "%s (ruby-%sp%d) [%s] (git rev %s)" % (engine, version, patchlevel, platform, RUBY_REVISION)
space.set_const(space.w_object, "RUBY_ENGINE", space.newstr_fromstr(engine))
space.set_const(space.w_object, "RUBY_VERSION", space.newstr_fromstr(version))
space.set_const(space.w_object, "RUBY_PATCHLEVEL", space.newint(patchlevel))
space.set_const(space.w_object, "RUBY_PLATFORM", space.newstr_fromstr(platform))
space.set_const(space.w_object, "RUBY_DESCRIPTION", space.newstr_fromstr(description))
space.set_const(space.w_object, "RUBY_REVISION", space.newstr_fromstr(RUBY_REVISION))

try:
(

0 comments on commit 2405d6d

Please sign in to comment.
You can’t perform that action at this time.