Skip to content

Instantly share code, notes, and snippets.

@jptix
Created September 10, 2009 08:22
Show Gist options
  • Save jptix/184411 to your computer and use it in GitHub Desktop.
Save jptix/184411 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def fix_trailing_space(file)
content = File.read(file)
content.gsub!(/[\t ]+$/, '')
File.open(file, "w") { |file| file.write(content) }
end
status = `git status`.split("\n")
files = status.map do |e|
e[/(modified|new file):\s*(.+?)$/, 2]
end.compact
abort "no modified files" if files.empty?
files.each do |file|
next unless File.file?(file)
p :fixing => file
fix_trailing_space file.strip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment