Minority Opinions

Not everyone can be mainstream, after all.

Beeminding Git

with 2 comments

After trying out Beeminder to get me to write more, I considered having it make sure I was getting actual work done at work.  Nearly everything we do is in a repository, lately git, so it made sense to base a graph on commits.  Sure, I could base it on time spent, but that’s even harder; I have utterly failed to get accurate counts of the time I spend on anything.  Besides, the results are more important than the process.

With that decided, there are two key metrics that commits give you: The number of commits, or the number of lines changed.  If you do anything resembling a large amount of work on a single commit, the former is grossly understated.  With any amount of copy-and-paste or other trivial changes, the latter is grossly overstated.  Together, they can give you some sort sense of what was happening, but for graphing, they’re probably more lies than reality.  They can also be easily gamed, so never, ever, use this as the basis of any sort of payroll or employment decision.

That said, I came up with a simple commit hook to count the lines added or changed by a commit, format it in the style of a Beeminder line, and append it to a file.  I have actually used that file to see what I was working on during a given time period. It uses the repository’s directory name as a convenient project tag; I could have had it look at .git/description, but that file has an unfortunate tendency to keep its default “Unnamed repository” message. Removed lines are ignored, because they don’t usually represent real work on my part. It also has an unfortunate tendency to duplicate rebased commits, but those can be spotted by having a date entirely out of order.

#!/bin/sh
#
# Count the number of lines changed,
# writing them out in Beeminder format.

cd "`dirname $0`/../.."
repo="`basename $PWD`"

git show --numstat --date=short | \
  perl -w -e '$date = ""; $lines = 0; $comment = "";' \
  -e 'while (<>) { /^Date: +([-\d]+)/ and $date = $1 and $date =~ y/-/ /; $comment or /^ +(.*)/ and $comment = $1; /^(\d+)/ and $lines += $1; }' \
  -e 'print qq($date $lines "'"$repo"': $comment"\n);' \
  >> ~/Documents/commit-lines.log

A graph of my work for the last six months shows the real problem:

Yes, there are three commits worth over twenty thousand lines each.  One was an upgrade of a third-party component, one included a large number of static assets from another team, and the third merged the branch that included the second commit.  Removing those three gives the graph a bit more texture, but there are still a few large outliers.

Maybe I can salvage something from it, perhaps by taking a logarithm, but it really hasn’t been important enough.  Nevertheless, it might be interesting to someone.

Advertisements

Written by eswald

10 Jan 2012 at 6:42 pm

Posted in Employment, Technology

2 Responses

Subscribe to comments with RSS.

  1. Yeah, this is tricky. Github uses a metric they call “impact” which purposefully does include lines deleted (I think it’s just lines added plus lines deleted). I think removing lines corresponds to work. You’re right that the amount of work won’t be in proportion to the number of lines, but, as you’ve demonstrated, that’s true for added lines as well.

    The only proxy I have for actual results is this metric: http://beeminder.com/meta/uvi — number of User-Visible Improvements to Beeminder. That of course is not automated.

    Finally, have you thought about using TagTime to track your time? http://messymatters.com/tagtime

    Daniel Reeves

    11 Jan 2012 at 12:55 pm

    • I considered TagTime, but only actually tried out the similar-looking packages available for my distro. They didn’t fare so well. I’ve just installed yours, so if it works well I’ll see about getting it to run on startup.

      eswald

      12 Jan 2012 at 11:33 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s