Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add short git revision to 'topaz -v'. #514

Merged
merged 3 commits into from
Mar 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import platform
import subprocess

import pytest

Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions topaz/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The const should be exposed on the Topaz module, not Object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what that is, then. Maybe:

space.set_const(space.w_topaz, "TOPAZ_REVISION", space.newstr_fromstr(TOPAZ_REVISION))
                      ^^^^^^^

Yeah?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. RUBY_REVISION is a toplevel constant on other rubies

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(y)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, @alex, so @parkr needs to revert that last name change, agreed?


try:
(
Expand Down