Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Created October 17, 2009 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garybernhardt/212258 to your computer and use it in GitHub Desktop.
Save garybernhardt/212258 to your computer and use it in GitHub Desktop.
# Loop through git revisions, counting lines of Python
# code, unit test code, cucumber code, and media. The
# paths and filenames are specific to my project; if
# you want to use this, you'll have to change them.
reverse() {
sed 'x;1!H;$!d;x'
}
(echo 'rev,python code,unit test,cucumber,media' &&
git rev-list HEAD |
reverse |
while read rev; do
git co $rev
echo "\
$rev \
, \
`find . -iname '*.py' | grep -v tests.py | xargs cat | wc -l` \
, \
`find . -iname 'tests.py' | xargs cat | wc -l` \
, \
`find features | grep -v watir | xargs cat | wc -l` \
, \
`find static | xargs cat | wc -l` \
" | sed 's/[[:space:]]//g'
done 2>/dev/null) > stats.csv
# As I originally typed it:
(echo 'rev,python code,unit test,cucumber,media' && git rev-list HEAD | sed 'x;1!H;$!d;x' | while read rev; do git co $rev; echo "$rev,`find . -iname '*.py' | grep -v tests.py | xargs cat | wc -l`,`find . -iname 'tests.py' | xargs cat | wc -l`,`find features | grep -v watir | xargs cat | wc -l`,`find static | xargs cat | wc -l`"; done 2>/dev/null) > stats.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment