Proper version tracking that is compatible with jeweler.
This commit is contained in:
parent
b2d2d46d58
commit
7a3bc728f1
27
Rakefile
27
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"
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user