Created
October 1, 2009 11:35
-
-
Save jesperronn/198914 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# THis script looks for orphan image files in a GIT project | |
# For now, it looks for usages in the current source files via git grep | |
# | |
# usage: | |
# unused [foldername] | |
# unused ../images | |
require 'fileutils' | |
ARGV[0] ||= 'images' | |
puts "looking for unused images in folder: " + ARGV[0] | |
FileUtils.cd(ARGV[0], :verbose => true) | |
files = Dir['**/*.png', '**/*.gif', '**/*.jpg'] | |
puts "found #{files.size} files:" | |
puts files.join(', ') | |
#puts Dir.glob("*") | |
puts '=====================verify current directory==============' | |
puts `pwd` | |
puts '=====================end verify============================' | |
puts | |
puts '=====================verify git ===========================' | |
git = `which git`.strip | |
puts "git command is found at '#{git}'" | |
puts '=====================end verify============================' | |
puts | |
puts '=====================verify git log works==================' | |
puts `git log -1 --oneline --stat` | |
puts '=====================end verify============================' | |
puts | |
puts '=====================verify git st works===================' | |
puts `git status` | |
puts "(exit code: #{$?.exitstatus})" | |
puts '=====================end verify============================' | |
puts | |
files[0..3].each do |f| | |
puts %(git grep #{f.strip}) | |
print `git grep #{f.strip}` | |
puts " <---- this line should NOT be blank!" | |
puts " (exit code: #{$?})" | |
end | |
puts "TOTAL #{files.size} FILES" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment