Commit 43783751 authored by Marius Rackwitz's avatar Marius Rackwitz

[Rakefile] Check all fixture tarballs for changes

All those which contain nested git repos should have all changes committed.
parent 1deed63d
...@@ -152,19 +152,22 @@ begin ...@@ -152,19 +152,22 @@ begin
namespace :fixture_tarballs do namespace :fixture_tarballs do
task :default => :unpack task :default => :unpack
tarballs = FileList['spec/fixtures/**/*.tar.gz']
desc 'Check fixture tarballs for pending changes' desc 'Check fixture tarballs for pending changes'
task :check_for_pending_changes do task :check_for_pending_changes do
repo_dir = 'spec/fixtures/banana-lib' tarballs.each do |tarball|
if Dir.exist?(repo_dir) && !Dir.chdir(repo_dir) { `git status --porcelain`.empty? } repo_dir = "#{File.dirname(tarball)}/#{File.basename(tarball, '.tar.gz')}"
puts red("[!] There are unsaved changes in '#{repo_dir}'. " \ if Dir.exist?(repo_dir) && Dir.exist?("#{repo_dir}/.git") && !Dir.chdir(repo_dir) { `git status --porcelain`.empty? }
'Please commit everything and run `rake spec:fixture_tarballs:rebuild`.') puts red("[!] There are unsaved changes in '#{repo_dir}'. " \
exit 1 'Please commit everything and run `rake spec:fixture_tarballs:rebuild`.')
exit 1
end
end end
end end
desc 'Rebuild all the fixture tarballs' desc 'Rebuild all the fixture tarballs'
task :rebuild => :check_for_pending_changes do task :rebuild => :check_for_pending_changes do
tarballs = FileList['spec/fixtures/**/*.tar.gz']
tarballs.each do |tarball| tarballs.each do |tarball|
basename = File.basename(tarball) basename = File.basename(tarball)
sh "cd #{File.dirname(tarball)} && rm #{basename} && env COPYFILE_DISABLE=1 tar -zcf #{basename} #{basename[0..-8]}" sh "cd #{File.dirname(tarball)} && rm #{basename} && env COPYFILE_DISABLE=1 tar -zcf #{basename} #{basename[0..-8]}"
...@@ -179,7 +182,6 @@ begin ...@@ -179,7 +182,6 @@ begin
exit 1 unless args[:force] exit 1 unless args[:force]
puts 'Continue anyway because `force` was applied.' puts 'Continue anyway because `force` was applied.'
end end
tarballs = FileList['spec/fixtures/**/*.tar.gz']
tarballs.each do |tarball| tarballs.each do |tarball|
basename = File.basename(tarball) basename = File.basename(tarball)
Dir.chdir(File.dirname(tarball)) do Dir.chdir(File.dirname(tarball)) do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment