Make sure revision version information is preserved when installing Haml as a gem.
This commit is contained in:
parent
ad10edf9af
commit
c0a88ed133
18
Rakefile
18
Rakefile
|
@ -51,6 +51,14 @@ END
|
||||||
# ----- Packaging -----
|
# ----- Packaging -----
|
||||||
|
|
||||||
require 'rake/gempackagetask'
|
require 'rake/gempackagetask'
|
||||||
|
require 'lib/haml'
|
||||||
|
|
||||||
|
# Before we run the package task,
|
||||||
|
# we want to create a REVISION file
|
||||||
|
# if we've checked out Haml from git
|
||||||
|
# and we aren't building for a release.
|
||||||
|
create_revision = Haml.version[:rev] && !Rake.application.top_level_tasks.include?('release')
|
||||||
|
p create_revision
|
||||||
|
|
||||||
spec = Gem::Specification.new do |spec|
|
spec = Gem::Specification.new do |spec|
|
||||||
spec.name = 'haml'
|
spec.name = 'haml'
|
||||||
|
@ -74,6 +82,7 @@ END
|
||||||
list.exclude('TODO')
|
list.exclude('TODO')
|
||||||
end.to_a
|
end.to_a
|
||||||
spec.executables = ['haml', 'html2haml', 'sass', 'css2sass']
|
spec.executables = ['haml', 'html2haml', 'sass', 'css2sass']
|
||||||
|
readmes << 'REVISION' if create_revision
|
||||||
spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile', 'init.rb'].to_a + readmes
|
spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile', 'init.rb'].to_a + readmes
|
||||||
spec.autorequire = ['haml', 'sass']
|
spec.autorequire = ['haml', 'sass']
|
||||||
spec.homepage = 'http://haml.hamptoncatlin.com/'
|
spec.homepage = 'http://haml.hamptoncatlin.com/'
|
||||||
|
@ -95,6 +104,15 @@ END
|
||||||
pkg.need_tar_bz2 = true
|
pkg.need_tar_bz2 = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "This is an internal task."
|
||||||
|
task :revision_file do
|
||||||
|
File.open('REVISION', 'w') { |f| f.puts Haml.version[:rev] } if create_revision
|
||||||
|
end
|
||||||
|
Rake::Task[:package].prerequisites.insert(0, :revision_file)
|
||||||
|
|
||||||
|
# We also need to get rid of this file after packaging.
|
||||||
|
Rake::Task[:package].enhance { File.delete('REVISION') if File.exists?('REVISION') }
|
||||||
|
|
||||||
task :install => [:package] do
|
task :install => [:package] do
|
||||||
sh %{gem install --no-ri pkg/haml-#{File.read('VERSION').strip}}
|
sh %{gem install --no-ri pkg/haml-#{File.read('VERSION').strip}}
|
||||||
end
|
end
|
||||||
|
|
|
@ -895,12 +895,16 @@ module Haml
|
||||||
}
|
}
|
||||||
@@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
|
@@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
|
||||||
|
|
||||||
if File.exists?(scope('.git/HEAD'))
|
if File.exists?(scope('REVISION'))
|
||||||
|
rev = File.read(scope('REVISION')).strip
|
||||||
|
elsif File.exists?(scope('.git/HEAD'))
|
||||||
rev = File.read(scope('.git/HEAD')).strip
|
rev = File.read(scope('.git/HEAD')).strip
|
||||||
if rev =~ /^ref: (.*)$/
|
if rev =~ /^ref: (.*)$/
|
||||||
rev = File.read(scope(".git/#{$1}")).strip
|
rev = File.read(scope(".git/#{$1}")).strip
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if rev
|
||||||
@@version[:rev] = rev
|
@@version[:rev] = rev
|
||||||
@@version[:string] << "." << rev[0...7]
|
@@version[:string] << "." << rev[0...7]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue