From 7a3bc728f148f031fed6fe47e5501427ad6f590c Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sat, 23 May 2009 23:30:49 -0700 Subject: [PATCH] Proper version tracking that is compatible with jeweler. --- Rakefile | 27 +++++++++++++++++++-------- lib/compass/version.rb | 16 ++++------------ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Rakefile b/Rakefile index 36db2cd6..2d88d141 100644 --- a/Rakefile +++ b/Rakefile @@ -60,6 +60,25 @@ rescue LoadError puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" end +desc "Record the current git revision." +task :REVISION do + require 'git' + + repo = Git.open('.') + open("REVISION", "w") do |f| + f.write(repo.object("HEAD").sha) + end +end + +desc "Commit the revision file." +task :commit_revision => :REVISION do + require 'git' + repo = Git.open('.') + repo.add("REVISION") + repo.commit("Record current revision for release.") +end + +task :release => :commit_revision desc "Compile Examples into HTML and CSS" task :examples do @@ -92,15 +111,7 @@ task :examples do end namespace :git do - desc "Perform normal operations required for pushing to github." - task :push => [:manifest, :gem] do - sh "git", "add", "Manifest", "compass.gemspec", "VERSION" - sh "git", "commit", "-m", "Updated Manifest and gemspec." - sh "git", "push", "origin", "master" - end task :clean do sh "git", "clean", "-fdx" end end - -task :manifest => :"git:clean" \ No newline at end of file diff --git a/lib/compass/version.rb b/lib/compass/version.rb index 13cf60c5..368028cf 100644 --- a/lib/compass/version.rb +++ b/lib/compass/version.rb @@ -12,7 +12,6 @@ module Compass return @version if defined?(@version) read_version_file - parse_version if r = revision @version[:rev] = r @@ -29,17 +28,10 @@ module Compass end def read_version_file - @version = { - :string => File.read(scope('VERSION')).strip - } - end - - def parse_version - dotted_string, @version[:label] = @version[:string].split(/-/, 2) - numbers = dotted_string.split('.').map { |n| n.to_i } - [:major, :minor, :teeny].zip(numbers).each do |attr, value| - @version[attr] = value - end + require 'yaml' + @version = YAML::load(File.read(scope('VERSION.yml'))) + @version[:string] = "#{@version[:major]}.#{@version[:minor]}.#{@version[:patch]}" + @version[:teeny] = @version[:patch] end def revision