From 9d942ca94e6a2784cd475defcf678446dba7b931 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 24 Apr 2008 21:30:48 -0700 Subject: [PATCH] Always create a REVISION file when building a package. --- Rakefile | 16 ++++++++-------- lib/haml.rb | 5 ++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Rakefile b/Rakefile index e7e9ab78..3396d21a 100644 --- a/Rakefile +++ b/Rakefile @@ -53,12 +53,6 @@ END 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') - spec = Gem::Specification.new do |spec| spec.name = 'haml' spec.summary = "An elegant, structured XHTML/XML templating engine.\nComes with Sass, a similar CSS templating engine." @@ -79,9 +73,9 @@ END readmes = FileList.new('*') do |list| list.exclude(/(^|[^.a-z])[a-z]+/) list.exclude('TODO') + list.include('REVISION') end.to_a spec.executables = ['haml', 'html2haml', 'sass', 'css2sass'] - readmes << 'REVISION' if create_revision spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile', 'init.rb'].to_a + readmes spec.autorequire = ['haml', 'sass'] spec.homepage = 'http://haml.hamptoncatlin.com/' @@ -105,7 +99,13 @@ END desc "This is an internal task." task :revision_file do - File.open('REVISION', 'w') { |f| f.puts Haml.version[:rev] } if create_revision + if Haml.version[:rev] && !Rake.application.top_level_tasks.include?('release') + File.open('REVISION', 'w') { |f| f.puts Haml.version[:rev] } + elsif Rake.application.top_level_tasks.include?('release') + File.open('REVISION', 'w') { |f| f.puts "(release)" } + else + File.open('REVISION', 'w') { |f| f.puts "(unknown)" } + end end Rake::Task[:package].prerequisites.insert(0, :revision_file) diff --git a/lib/haml.rb b/lib/haml.rb index f0870db2..dad8c379 100644 --- a/lib/haml.rb +++ b/lib/haml.rb @@ -937,7 +937,10 @@ module Haml if File.exists?(scope('REVISION')) rev = File.read(scope('REVISION')).strip - elsif File.exists?(scope('.git/HEAD')) + rev = nil if rev !~ /a-f0-9+/ + end + + if rev.nil? && File.exists?(scope('.git/HEAD')) rev = File.read(scope('.git/HEAD')).strip if rev =~ /^ref: (.*)$/ rev = File.read(scope(".git/#{$1}")).strip