#!/usr/bin/env ruby # post-commit - a hook to talk to the svnwatch rbot plugin # author(s): Robby Russell and Ben Bleything of the PDX.rb # # This file should be placed in the repository's hooks directory require 'drb' # Configuration Options @conf = { :port => '7666', # 7666 (you will need this to be the same in post-commit) :host => 'localhost' # localhost, don't set to remote ip unless you know what you are doing } # Okay. So we get two args from svn. # # [1] - repo path # [2] - revision number # # We then use this information to gather relevant data about the commit # and do with it as we please. path = ARGV[0] rev = ARGV[1] if (path.nil? || rev.nil?) puts "Usage: post-commit " exit end path = File.expand_path(path) DRb.start_service bot = DRbObject.new(nil, "druby://#{@conf[:host]}:#{@conf[:port]}") # The array contains this data: # [0]: committer # [1]: timestamp of commit # [2]: Size of log entry, in bytes # [3]: Log message info_array = `svnlook info --revision #{rev} #{path}`.strip.split(/\n/, 4) # dumb idea, it would wrap too many lines if multiple files... #changed = `svnlook changed -r #{rev} #{path}`.strip # guess what the repository name is repos = path.split(/\//).last commit_info = { :author => info_array[0], :revision => rev, :repository => repos, :log => info_array[3].gsub(/\n/, ' ') } bot.svn_commit commit_info