Created
July 19, 2021 23:31
-
-
Save jthodge/bfd3b5a9da480713a04c185fea5cbf1f to your computer and use it in GitHub Desktop.
Script for iterating over git revisions and computing statistics for each
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
#!/bin/bash | |
set -e | |
file_pattern=$1 | |
function main { | |
for rev in `revisions`; do | |
echo "`number_of_lines` `commit_description`" | |
done | |
} | |
function revisions { | |
git rev-list --reverse HEAD | |
} | |
funtion commit_description { | |
git log --oneline -1 $rev | |
} | |
function number_of_lines { | |
git ls-tree -r $rev | | |
grep "$file_pattern" | | |
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