Created
September 19, 2014 16:16
-
-
Save robskillington/776e6a7e34863848ede8 to your computer and use it in GitHub Desktop.
numstatall - pipe the output of `git diff --numstat <commit-ish>` to get total add and deletions
This file contains hidden or 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 coffee | |
readline = require 'readline' | |
rl = readline.createInterface | |
input: process.stdin | |
terminal: false | |
stat = {add: 0, del: 0} | |
rl.on 'line', (line)-> | |
diff = line.split '\t' | |
if diff.length == 3 | |
add = parseInt diff[0] | |
del = parseInt diff[1] | |
if !isNaN(add) && !isNaN(del) | |
stat.add += add | |
stat.del += del | |
format = (num)-> | |
num.toString().replace /(\d)(?=(\d{3})+(?!\d))/g, "$1," | |
rl.on 'close', ()-> | |
console.log "total add: #{format(stat.add)} del: #{format(stat.del)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment