Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.