Created
February 13, 2009 19:22
-
-
Save fizx/64054 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 | |
# | |
# Example: | |
# $: git log --numstat -w --summary --date=iso | this.rb | |
# <timestamp> <added> <deleted> | |
# | |
require "time" | |
DATE = /^Date:(.*)/ | |
DIFF = /^(\d+)\s+(\d+)/ | |
def output(ts, add, del) | |
return unless ts | |
puts "#{ts}\t#{add}\t#{del}" | |
end | |
timestamp = nil | |
added = 0 | |
deleted = 0 | |
while line = STDIN.gets | |
if line =~ DATE | |
output(timestamp, added, deleted) | |
timestamp = Time.parse($1).to_i | |
added = 0 | |
deleted = 0 | |
elsif line =~ DIFF | |
added += $1.to_i | |
deleted += $2.to_i | |
end | |
end | |
output(timestamp, added, deleted) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment