Skip to content

Instantly share code, notes, and snippets.

@cyu
Created February 5, 2011 04:41
Show Gist options
  • Save cyu/812211 to your computer and use it in GitHub Desktop.
Save cyu/812211 to your computer and use it in GitHub Desktop.
Twittering Subversion Updates
begin
require 'rubygems'
require 'twitter'
rescue LoadError
%x{echo "repo:#{ARGV[0]} rev: #{ARGV[1]}" > /tmp/svn-hooks.log}
%x{echo "Error: #{$!} trace:#{caller}" >> /tmp/svn-hooks.log}
end
def gather_and_post(repo_path, revision)
svnlook = '/usr/bin/svnlook'
commit_dirs_changed = `#{svnlook} dirs-changed #{repo_path} -r #{revision}`
return unless commit_dirs_changed.split(/\n/)[0] =~ /trunk/
commit_author = `#{svnlook} author #{repo_path} -r #{revision}`.chop
commit_log = `#{svnlook} log #{repo_path} -r #{revision}`
commit_changed = `#{svnlook} changed #{repo_path} -r #{revision}`
changed_count = commit_changed.split("\n").length
message = "SVN: Rev. #{revision.to_s} by #{commit_author}"
message << " \"#{commit_log}\" (#{changed_count} Change(s))"
# TODO set the email and password below.
Twitter::Base.new(TWITTER_EMAIL, TWITTER_PASS).post(message)
end
begin
gather_and_post(ARGV[0], ARGV[1])
rescue
%x{echo "repo:#{ARGV[0]} rev: #{ARGV[1]}" > /tmp/svn-hooks.log}
%x{echo "Error: #{$!} trace:#{caller}" >> /tmp/svn-hooks.log}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment