Tuesday, October 2, 2007

sfight!

I played around yesterday when I got bored and wrote a little script which pits developers on a project against each other to see who has the most subversion commits. It doesn't really mean too much who wins since you can have plenty of little commits that fix things, but it is just fun to do to see who wins! This script assumes the developers on the project have separate subversion logins. Enjoy!


#!/usr/bin/env ruby
developers = ARGV.select {|arg| !arg.empty? && !arg.nil?}
raise "You need two developers to fight" if developers.size < 2

log = `svn log`
separator = log.scan(/^-.*?-$/).first
log_entries = log.split(separator)[1..-2]
names = log_entries.collect {|entry| entry.split(" | ")[1]}

numbers = developers.collect {|developer| names.select {|entry| entry == developer}.size}

results = []
developers.each_with_index {|developer, i| results << "#{numbers[i].to_s.ljust(3)}- #{developer}"}

puts results.sort {|x, y| y.scan(/\d+/).first.to_i <=> x.scan(/\d+/).first.to_i}


Use it like this (assuming you chmod'ed it to be executable, and put it into your ./script directory):

./script/sfight developer1 developer2 developer3


2 comments:

Anonymous said...

Hi,

I am regular visitor of this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]siannopollo.blogspot.com really contains lot of useful information. Let me tell you one thing guys, some time we really forget to pay attention towards our health. Let me present you with one fact here. Research points that nearly 70% of all U.S. grownups are either chubby or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] So if you're one of these people, you're not alone. In fact, most of us need to lose a few pounds once in a while to get sexy and perfect six pack abs. Now the question is how you are planning to have quick weight loss? [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss[/url] is really not as tough as you think. Some improvement in of daily activity can help us in losing weight quickly.

About me: I am blogger of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also mentor who can help you lose weight quickly. If you do not want to go under hard training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effective weight loss.

Chatty said...

Really you have done great job,There are may person searching about that now they will find enough resources by your post.I like this blog..
Blogger how when you visit my site,
My Site created for men's health,
Here the best method for you and get the best Penis Enlargement Pills today.

Penis Pills | Penis Device | Penis Exercise