Created
February 5, 2011 04:41
-
-
Save cyu/812211 to your computer and use it in GitHub Desktop.
Twittering Subversion Updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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