Skip to content

Instantly share code, notes, and snippets.

@relrod
Created February 7, 2010 22:08
Show Gist options
  • Save relrod/297718 to your computer and use it in GitHub Desktop.
Save relrod/297718 to your computer and use it in GitHub Desktop.
--- webhooks.rb 2010-02-07 17:07:34.000000000 -0500
+++ fbihg.rb 2010-02-07 17:07:23.000000000 -0500
@@ -47,6 +47,26 @@
FBI::Client.publish 'github', data
}
+Hooks['/bitbucket'] = lambda {|env|
+ data = env['rack.input'].read
+ data = JSON.parse CGI::unescape(data[8..-1])
+
+ output = data['commits'].map do |commit|
+
+ {
+ :project => data['repository']['name'],
+ :owner => data['repository']['owner'],
+ :fork => false,
+ :author => commit['author'],
+ :branch => commit['branch'],
+ :commit => commit['node'],
+ :message => commit['message'],
+ :url => "http://bitbucket.org/#{data['repository']['owner']}/#{data['repository']['name']}/changeset/#{commit['node']}"
+ }
+ end
+ FBI::Client.publish 'commits', output
+ FBI::Client.publish 'bitbucket', data
+}
Webhooks = Rack::Builder.new do
use Rack::Reloader, 0
use Rack::ContentLength
@@ -64,3 +84,4 @@
EM.next_tick do
FBI::Client.connect 'thin', 'hil0l'
end
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment