Skip to content

Instantly share code, notes, and snippets.

@fpinzn
Created March 14, 2013 01:17
Show Gist options
  • Save fpinzn/5158032 to your computer and use it in GitHub Desktop.
Save fpinzn/5158032 to your computer and use it in GitHub Desktop.
Bash script to generate stats, in the shape of a csv file. Each line is composed by the one-line git log of each commit and the number of lines of code tracked. Extracted from https://www.destroyallsoftware.com/screencasts/catalog/statistics-over-git-repositories
#!/bin/bash
set -e
function main {
git rev-list --reverse HEAD |
while read rev; do
echo "'`commit_description`', '`number_of_lines`'"
done > stats.csv
}
function commit_description {
git log --oneline -1 $rev | cat
}
function number_of_lines {
git ls-tree -r $rev |
awk '{print $3}' |
xargs git show |
wc -l;
}
MAIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment