2009-12-08 09:28:03 +03:00
|
|
|
require 'rake/testtask'
|
|
|
|
|
2010-04-12 02:19:49 +04:00
|
|
|
#
|
|
|
|
# Helpers
|
|
|
|
#
|
2009-12-08 13:12:29 +03:00
|
|
|
|
2010-04-12 02:19:49 +04:00
|
|
|
def command?(command)
|
2010-04-22 04:16:41 +04:00
|
|
|
`type -t #{command}`
|
|
|
|
$?.success?
|
2009-12-09 16:32:02 +03:00
|
|
|
end
|
|
|
|
|
2009-12-09 07:05:17 +03:00
|
|
|
task :load_hub do
|
|
|
|
$LOAD_PATH.unshift 'lib'
|
|
|
|
require 'hub'
|
2009-12-08 13:12:29 +03:00
|
|
|
end
|
|
|
|
|
2010-04-12 02:19:49 +04:00
|
|
|
task :check_dirty do
|
|
|
|
if !`git status`.include?('nothing to commit')
|
|
|
|
abort "dirty index - not publishing!"
|
|
|
|
end
|
|
|
|
end
|
2009-12-08 13:03:17 +03:00
|
|
|
|
|
|
|
|
2010-04-12 02:19:49 +04:00
|
|
|
#
|
|
|
|
# Tests
|
|
|
|
#
|
2009-12-08 13:03:17 +03:00
|
|
|
|
2010-04-12 02:19:49 +04:00
|
|
|
task :default => :test
|
2009-12-08 13:03:17 +03:00
|
|
|
|
2010-04-12 02:19:49 +04:00
|
|
|
if command? :turn
|
|
|
|
desc "Run tests"
|
|
|
|
task :test do
|
|
|
|
suffix = "-n #{ENV['TEST']}" if ENV['TEST']
|
|
|
|
sh "turn test/*.rb #{suffix}"
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Rake::TestTask.new do |t|
|
|
|
|
t.libs << 'lib'
|
|
|
|
t.ruby_opts << '-rubygems'
|
|
|
|
t.pattern = 'test/**/*_test.rb'
|
|
|
|
t.verbose = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if command? :kicker
|
|
|
|
desc "Launch Kicker (like autotest)"
|
|
|
|
task :kicker do
|
|
|
|
puts "Kicking... (ctrl+c to cancel)"
|
|
|
|
exec "kicker -e rake test lib"
|
|
|
|
end
|
|
|
|
end
|
2009-12-08 13:03:17 +03:00
|
|
|
|
|
|
|
|
2010-04-12 02:19:49 +04:00
|
|
|
#
|
|
|
|
# Ron
|
|
|
|
#
|
2009-12-08 13:03:17 +03:00
|
|
|
|
2010-04-12 02:19:49 +04:00
|
|
|
if command? :ronn
|
|
|
|
desc "Show the manual"
|
|
|
|
task :man => "man:build" do
|
|
|
|
exec "man man/hub.1"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Build the manual"
|
|
|
|
task "man:build" do
|
2010-04-17 00:02:28 +04:00
|
|
|
sh "ronn -br5 --organization=DEFUNKT --manual='Git Manual' man/*.ronn"
|
2009-12-08 11:26:59 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-12-11 19:44:42 +03:00
|
|
|
|
2010-04-12 02:19:49 +04:00
|
|
|
#
|
|
|
|
# Gems
|
|
|
|
#
|
|
|
|
|
|
|
|
desc "Build standalone script"
|
|
|
|
task :standalone => :load_hub do
|
|
|
|
require 'hub/standalone'
|
|
|
|
Hub::Standalone.save('hub')
|
2009-12-11 19:44:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Install standalone script and man pages"
|
|
|
|
task :install => :standalone do
|
|
|
|
prefix = ENV['PREFIX'] || ENV['prefix'] || '/usr/local'
|
|
|
|
|
|
|
|
FileUtils.mkdir_p "#{prefix}/bin"
|
|
|
|
FileUtils.cp "hub", "#{prefix}/bin"
|
|
|
|
|
|
|
|
FileUtils.mkdir_p "#{prefix}/share/man/man1"
|
|
|
|
FileUtils.cp "man/hub.1", "#{prefix}/share/man/man1"
|
|
|
|
end
|
|
|
|
|
2009-12-08 12:14:16 +03:00
|
|
|
desc "Publish to GitHub Pages"
|
2010-03-09 12:13:09 +03:00
|
|
|
task :pages => [ "man:build", :check_dirty, :standalone ] do
|
2009-12-11 19:44:49 +03:00
|
|
|
cp "man/hub.1.html", "html"
|
2010-03-09 12:10:33 +03:00
|
|
|
sh "git checkout gh-pages"
|
|
|
|
sh "mv hub standalone"
|
|
|
|
sh "git add standalone*"
|
|
|
|
sh "mv html hub.1.html"
|
|
|
|
sh "git add hub.1.html"
|
|
|
|
sh "git commit -m 'update standalone'"
|
|
|
|
sh "git push origin gh-pages"
|
|
|
|
sh "git checkout master"
|
2009-12-08 12:16:17 +03:00
|
|
|
puts :done
|
2009-12-08 12:14:16 +03:00
|
|
|
end
|