Skip to content

Instantly share code, notes, and snippets.

@phiggins
Created June 29, 2016 17:27
Show Gist options
  • Save phiggins/bab4a02141ee8231734626440f34c688 to your computer and use it in GitHub Desktop.
Save phiggins/bab4a02141ee8231734626440f34c688 to your computer and use it in GitHub Desktop.
branches = %w[ master switch-to-sassc ]
tmp = Pathname.new(Dir.tmpdir)
branches.each do |branch|
asset_dir = tmp + "assets_#{branch}"
if asset_dir.exist?
puts "#{asset_dir} exists, skipping"
next
end
FileUtils.rm_rf Rails.root + "tmp/cache"
FileUtils.rm_rf Rails.root + "public/assets"
print "precompiling #{branch}... "
puts(Benchmark.realtime {
system "git checkout #{branch} && rake assets:precompile", out: IO::NULL, err: IO::NULL
})
FileUtils.mv (Rails.root + "public/assets"), asset_dir
end
first, second = *branches.map { |branch|
Dir[tmp + "assets_#{branch}" + "**" + "*.css"].sort
}
first.zip(second).each do |file1, file2|
puts "diffing:"
puts file1
puts file2
# Remove lines of just whitespace
#[file1, file2].each { |file| `sed -i "/^\s*$/d" #{file}` }
# Remove comments
#[file1, file2].each { |file| `sed -i "|^/\*|d" #{file}` }
css_diff = `css-diff #{file1} #{file2}`
if css_diff.strip == "true"
puts `diff --text --ignore-space-change --report-identical-files #{file1} #{file2}`
else
puts "Files are syntactically identical."
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment