#!/bin/bash cmd=kvm-xxx function fatal { echo "$cmd: $*" 1>&2 exit 1 } function process { ifdef=0 comments=0 err=/tmp/kvm-xxx.$$ if [[ -n $1 ]]; then since="--since=\"$1 weeks ago\"" fi for commit in `eval git log --format=%ct:%H $since | sort -n`; do hash=`echo $commit | cut -d: -f2` date=`echo $commit | cut -d: -f1` git checkout $hash > /dev/null 2> $err if [[ "$?" -ne 0 ]]; then fatal "unable to git checkout $hash: `cat $err`" fi files=`git ls-tree $hash | awk '{ print $4 }'` ifdef=`grep '#ifdef XXX' $files 2> /dev/null | \ grep -v '#endif' | wc -l` comments=`grep '* XXX' $files 2> /dev/null | \ grep -v '#endif' | wc -l` echo $date $ifdef $comments done rm $err 2> /dev/null now=`date +%s` if [[ $now -eq "s" ]]; then # # Seriously, WTF date(1)? Can we try to suck less?! # now=`pfexec dtrace -q \ -n BEGIN'{trace(walltimestamp / 1000000000); exit(0)}'` if [[ $? -ne 0 ]]; then fatal "couldn't get current Unix time" fi fi echo $now $ifdef $comments } gpl=/tmp/kvm-xxx-$$.gpl out=/tmp/kvm-xxx-$$.out cat /dev/null > $out if [[ ! -d .git ]]; then fatal "must be in the root directory of the repo" fi if [[ `uname -s` == "SunOS" ]]; then make clean fi if ! git checkout master > /dev/null 2>&1 ; then fatal "could not checkout master" fi echo "$cmd: processing all-time data..." process > $out-all echo "$cmd: processing data over last month..." process 4 > $out-month echo "$cmd: processing data over last week..." process 1 > $out-week git checkout master > /dev/null 2>&1 cat > $gpl <