Skip to content

Instantly share code, notes, and snippets.

@henvic
Created April 2, 2015 19:39
Show Gist options
  • Save henvic/87398ef39f3495f38160 to your computer and use it in GitHub Desktop.
Save henvic/87398ef39f3495f38160 to your computer and use it in GitHub Desktop.
Plato history importer
#!/bin/bash
TITLE="Project Name"
REPORT_DIR="reports/complexity"
FILES="lib test bin tasks gulpfile.js"
BACK=$1
JSHINTRC=$2
OFFSET=$3
STEPS=$4
COUNT=0
LEFT=$BACK
ORIG_HEAD_COMMIT=`git rev-parse ORIG_HEAD`
if [ -d "$REPORT_DIR" ]; then
echo Remove the $REPORT_DIR directory first.
exit
fi
if [ ! $BACK ]; then
echo "Use: sh $0 <number of commits> <jshintrc> <offset> <steps>"
exit
fi
if [ ! $JSHINTRC ]; then
echo "Warning: No .jshintrc configured.">&2
fi
if [ ! $4 ]; then
OFFSET=0
fi
if [ ! $STEPS ]; then
STEPS=30
fi
while [ 0 -le $LEFT ]; do
git checkout $ORIG_HEAD_COMMIT~$(($LEFT - $OFFSET - 1))
CURRENT_COMMIT=`git rev-parse HEAD`
if [ -f $JSHINTRC ]; then
JSHINT_OPT="--jshint $JSHINTRC"
fi
COUNT=$(( $COUNT + 50 ))
LEFT=$(( $BACK - $COUNT ))
if [ "$LEFT" -lt "0" ]; then
exit
fi
echo "Creating Plato report for commit $CURRENT_COMMIT ($COUNT/$BACK)"
node_modules/plato/bin/plato \
--dir "$REPORT_DIR" --recurse \
--title "$TITLE" \
--date "`git show -s --format=%ct`" \
$JSHINT_OPT \
$FILES
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment