#!/opt/local/bin/ruby DARCS = '/usr/local/bin/darcs' repos = ARGV[0] code_root = ARGV[1] || '.' tmp_dir = "/tmp/#{File.basename(repos)}-tugger" if File.exists? tmp_dir # Just get the count first_count = count = File.open("#{tmp_dir}/tugger-data", 'r').readlines.last.split(' ').first.to_i + 1 puts "Restarting from change #{count}" else # Need to initialize # Get the first patch first_patch = / \* (.+)\n/.match(IO.popen("cd #{repos};#{DARCS} changes --reverse").readlines[1])[1] puts "Copying repository ..." %x{#{DARCS} get --to-patch="#{first_patch}" #{repos} #{tmp_dir}} first_count = count = 1 puts "Beginning analysis ..." end Dir.chdir "#{tmp_dir}/#{code_root}" f1 = File.open("#{tmp_dir}/tugger-data", 'a') until %x{echo "yd" | #{DARCS} pull} =~ /No remote changes/ if %x{rake stats} =~ /Code LOC:\s+(\d+)\s+Test LOC:\s+(\d+)/ f1.write "#{count} #{$1} #{$2}\n" end puts "Wrote change #{count}" count = count + 1 end f1.close puts "Data completed for patches #{first_count} through #{count - 1}"