Last active
October 8, 2020 12:31
-
-
Save AlexanderWingard/4336d092b3966074410dbc0e29eb7132 to your computer and use it in GitHub Desktop.
Character count csv of folder in git
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 | |
for commit in $(git rev-list --reverse --topo-order HEAD -- .) | |
do | |
sum=0 | |
for file in $(git ls-tree -r --name-only $commit) | |
do | |
if [[ $(git show $commit:./$file | file -ib -) =~ "text/" ]] | |
then | |
count=$(git show $commit:./$file | tr -d '[:space:]' | wc -c) | |
sum=$((sum + count)) | |
fi | |
done | |
meta=$(git log -n1 --format="format:%cI,%h,%an" $commit) | |
title=$(git log -n1 --format="format:%s" $commit | tr -d \") | |
echo "$sum,$meta,\"$title\"" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment