Skip to content

Instantly share code, notes, and snippets.

@base698
Last active August 12, 2016 18:08
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 base698/10943264 to your computer and use it in GitHub Desktop.
Save base698/10943264 to your computer and use it in GitHub Desktop.
Find commits in a workspace for listed languages
#!/bin/bash
source_reg='\b(scala|cpp|js|java|coffee|rb|java|clj|py|groovy|html|ejs|sh|cljs)\b';
awk_counts='{
counts[tolower($1)]++
}
END {
for(type in counts) {
print(type, counts[type])
}
}';
awk_sums='BEGIN {}
{
total+=$2;
counts[$1]+=$2;
}
END {
printf("%-10s %-8s %-8s \n","type", "commits", "percent");
for(type in counts) {
printf("%-10s %-8d %-5.2f \n",type, counts[type], counts[type]*100/total)
}
}';
find . -type d | while read line
do
if ls -a "$line" | egrep '^\.git$'
then
cd "$line"
git log -p -E --author="$1" | grep diff | egrep -o "\.[a-zA-Z]{1,8}" | egrep -io "$source_reg" | awk "$awk_counts"
cd -
fi
done | awk "$awk_sums"
@base698
Copy link
Author

base698 commented Aug 12, 2016

usage: ./stats.sh justin@email.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment