Skip to content

Instantly share code, notes, and snippets.

@andrewchilds
Created July 3, 2017 14:59
Show Gist options
  • Select an option

  • Save andrewchilds/319e98bfed18247db031fa4f7765a16f to your computer and use it in GitHub Desktop.

Select an option

Save andrewchilds/319e98bfed18247db031fa4f7765a16f to your computer and use it in GitHub Desktop.

Revisions

  1. andrewchilds created this gist Jul 3, 2017.
    28 changes: 28 additions & 0 deletions getAgeOfCodebase.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/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