-
-
Save aug2uag/f0aa19742d3b71c906cc 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 bash | |
# generate git log array in JSON: | |
git log \ | |
--pretty=format:'{%n "commit": "%H",%n "author": "%an <%ae>",%n "date": "%ad",%n "message": "%f"%n},' \ | |
$@ | \ | |
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \ | |
perl -pe 's/},]/}]/' > logAcc.json |
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 bash | |
# generate git log --stats array in JSON | |
git log \ | |
--numstat \ | |
--format='%H' \ | |
$@ | \ | |
perl -lawne ' | |
if (defined $F[1]) { | |
print qq#{"insertions": "$F[0]", "deletions": "$F[1]", "path": "$F[2]"},# | |
} elsif (defined $F[0]) { | |
print qq#],\n"$F[0]": [# | |
}; | |
END{print qq#],#}' | \ | |
tail -n +2 | \ | |
perl -wpe 'BEGIN{print "{"}; END{print "}"}' | \ | |
tr '\n' ' ' | \ | |
perl -wpe 's#(]|}),\s*(]|})#$1$2#g' | \ | |
perl -wpe 's#,\s*?}$#}#' > logStats.json |
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
/* | |
* OPTIONAL: use this Node.js expression to merge the data structures | |
* created by the two shell scripts above | |
*/ | |
var logAcc, lstat; | |
logAcc = require('logAcc.json'); | |
lstat = require('logStats.json'); | |
logAcc.map(function(o){ | |
o.stat = lstat[o.commit]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment