Browse files

Rails Edge info returns the latest git commit hash [#36 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
1 parent a4fc93c commit bf1b1e0925085811f0b58bb4093e678438ea0236 @fesplugas fesplugas committed with josh Apr 22, 2008
Showing with 39 additions and 43 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +5 −5 railties/builtin/rails_info/rails/info.rb
  3. +32 −38 railties/test/rails_info_test.rb
View
2 railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Rails Edge info returns the latest git commit hash [Francesc Esplugas]
+
* Added Rails.public_path to control where HTML and assets are expected to be loaded from (defaults to Rails.root + "/public") #11581 [nicksieger]
* rake time:zones:local finds correct base utc offset for zones in the Southern Hemisphere [Geoff Buesing]
View
10 railties/builtin/rails_info/rails/info.rb
@@ -29,8 +29,8 @@ def component_version(component)
"#{component.classify}::VERSION::STRING".constantize
end
- def edge_rails_revision(info = svn_info)
- info[/^Revision: (\d+)/, 1] || freeze_edge_version
+ def edge_rails_revision(info = git_info)
+ info[/commit ([a-z0-9-]+)/, 1] || freeze_edge_version
end
def freeze_edge_version
@@ -67,10 +67,10 @@ def rails_vendor_root
@rails_vendor_root ||= "#{RAILS_ROOT}/vendor/rails"
end
- def svn_info
+ def git_info
env_lang, ENV['LC_ALL'] = ENV['LC_ALL'], 'C'
Dir.chdir(rails_vendor_root) do
- silence_stderr { `svn info` }
+ silence_stderr { `git log -n 1` }
end
ensure
ENV['LC_ALL'] = env_lang
@@ -98,7 +98,7 @@ def svn_info
end
end
- # The Rails SVN revision, if it's checked out into vendor/rails.
+ # The Rails Git revision, if it's checked out into vendor/rails.
property 'Edge Rails revision' do
edge_rails_revision
end
View
70 railties/test/rails_info_test.rb
@@ -23,27 +23,21 @@ def test_edge_rails_revision_not_set_when_svn_info_is_empty
end
assert !property_defined?('Test that this will not be defined')
end
-
+
def test_edge_rails_revision_extracted_from_svn_info
Rails::Info.property 'Test Edge Rails revision' do
Rails::Info.edge_rails_revision <<-EOS
-Path: .
-URL: http://www.rubyonrails.com/svn/rails/trunk
-Repository UUID: 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-Revision: 2881
-Node Kind: directory
-Schedule: normal
-Last Changed Author: sam
-Last Changed Rev: 2881
-Last Changed Date: 2005-11-04 21:04:41 -0600 (Fri, 04 Nov 2005)
-Properties Last Updated: 2005-10-28 19:30:00 -0500 (Fri, 28 Oct 2005)
+ commit 420c4b3d8878156d04f45e47050ddc62ae00c68c
+ Author: David Heinemeier Hansson <david@loudthinking.com>
+ Date: Sun Apr 13 17:33:27 2008 -0500
+ Added Rails.public_path to control where HTML and assets are expected to be loaded from
EOS
end
-
- assert_property 'Test Edge Rails revision', '2881'
+
+ assert_property 'Test Edge Rails revision', '420c4b3d8878156d04f45e47050ddc62ae00c68c'
end
-
+
def test_property_with_block_swallows_exceptions_and_ignores_property
assert_nothing_raised do
Rails::Info.module_eval do
@@ -52,54 +46,54 @@ def test_property_with_block_swallows_exceptions_and_ignores_property
end
assert !property_defined?('Bogus')
end
-
+
def test_property_with_string
Rails::Info.module_eval do
property 'Hello', 'World'
end
assert_property 'Hello', 'World'
end
-
+
def test_property_with_block
Rails::Info.module_eval do
property('Goodbye') {'World'}
end
assert_property 'Goodbye', 'World'
end
-
+
def test_component_version
assert_property 'Active Support version', ActiveSupport::VERSION::STRING
end
-
+
def test_components_exist
Rails::Info.components.each do |component|
dir = File.dirname(__FILE__) + "/../../" + component.gsub('_', '')
assert File.directory?(dir), "#{component.classify} does not exist"
end
end
-protected
- def svn_info=(info)
- Rails::Info.module_eval do
- class << self
- def svn_info
- info
+ protected
+ def svn_info=(info)
+ Rails::Info.module_eval do
+ class << self
+ def svn_info
+ info
+ end
end
end
end
- end
-
- def properties
- Rails::Info.properties
- end
- def property_defined?(property_name)
- properties.names.include? property_name
- end
-
- def assert_property(property_name, value)
- raise "Property #{property_name.inspect} not defined" unless
- property_defined? property_name
- assert_equal value, properties.value_for(property_name)
- end
+ def properties
+ Rails::Info.properties
+ end
+
+ def property_defined?(property_name)
+ properties.names.include? property_name
+ end
+
+ def assert_property(property_name, value)
+ raise "Property #{property_name.inspect} not defined" unless
+ property_defined? property_name
+ assert_equal value, properties.value_for(property_name)
+ end
end

0 comments on commit bf1b1e0

Please sign in to comment.