Created
September 10, 2009 08:22
-
-
Save jptix/184411 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 | |
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