2# This script gives me a brief summary of my current Git changes, by
3# telling me the number of lines I'm adding/deleting, e.g.
8# It's just for my own amusement, and shouldn't be relied on for
14`git diff`.each_line do |line|
15 if line.start_with? "-" and not line.start_with? "--- "
17 elsif line.start_with? "+" and not line.start_with? "+++ "
22`git diff --cached`.each_line do |line|
23 if line.start_with? "-" and not line.start_with? "--- "
25 elsif line.start_with? "+" and not line.start_with? "+++ "
30# https://stackoverflow.com/q/1489183/1558022
32 def colorize(color_code)
33 "\e[#{color_code}m#{self}\e[0m"
45additions = additions.to_s
46deletions = deletions.to_s
48max_len = [additions.size, deletions.size].max
50puts "+++ #{additions.rjust(max_len)} addition#{additions == "1" ? "" : "s"}".green
51puts "--- #{deletions.rjust(max_len)} deletion#{deletions == "1" ? "" : "s"}".red