Created
July 3, 2017 14:59
-
-
Save andrewchilds/319e98bfed18247db031fa4f7765a16f to your computer and use it in GitHub Desktop.
Creates a histogram CSV file of the age of every line of code in a directory
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 | |
APP_DIR="$1" | |
TEMP_FILE="codebase-age-histogram.txt" | |
OUTPUT_FILE="codebase-age-histogram.csv" | |
pushd $APP_DIR | |
APP_FILES=`find . -type f -follow -print` | |
rm -f $TEMP_FILE | |
touch $TEMP_FILE | |
for APP_FILE in $APP_FILES; do | |
echo "Annotating $APP_FILE..." | |
git annotate $APP_FILE | awk '{ print $4 }' >> $TEMP_FILE | |
done | |
sort -n $TEMP_FILE | uniq -c | sed -e 's/^ *//;s/ /,/' > $OUTPUT_FILE | |
rm -f $TEMP_FILE | |
echo "" | |
echo "Done! Histogram CSV saved to $OUTPUT_FILE" | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment