Created
November 13, 2009 21:18
-
-
Save bkaney/234172 to your computer and use it in GitHub Desktop.
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
require 'net/http' | |
require 'uri' | |
require 'json' | |
require 'daemons' | |
# EDIT POST_RECEIVE_URL | |
POST_RECEIVE_URL = "http://integrity/push" | |
old_head, new_head, ref = STDIN.gets.split | |
revision_text = `git rev-list --pretty=medium #{new_head} ^#{old_head}` | |
revisions = [] | |
revision_text.split( /\n/ ).each_slice( 6 ) { |s| | |
sha1 = s[0][ /commit (\w+)/, 1 ] | |
s[1] =~ /Author: (\w+) <(.+?)>/ | |
author_name, author_email = $1, $2 | |
timestamp = s[2][ /Date: +(.+?) -0/, 1 ] | |
message = s[4..-1].join.strip | |
revisions << { | |
'id' => sha1, | |
'author' => { | |
'email' => author_email, | |
'name' => author_name, | |
}, | |
'message' => message, | |
'timestamp' => timestamp, | |
} | |
} | |
if revisions.empty? | |
exit 0 | |
end | |
payload = { | |
'payload' => { | |
"ref" => ref, | |
"commits" => revisions, | |
}.to_json | |
} | |
Daemons.daemonize | |
uri = URI.parse(POST_RECEIVE_URL) | |
post_req = Net::HTTP::Post.new(uri.path) | |
post_req.basic_auth 'username', 'password' | |
post_req.set_form_data(payload, ';') | |
response = nil | |
req = Net::HTTP.new(uri.host, uri.port) | |
req.start {|http| response = http.request(post_req)} | |
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
[Fri Nov 13 16:28:10 2009] [error] [client 216.93.243.245] Premature end of script headers: push | |
[ pid=28191 file=ext/apache2/Hooks.cpp:682 time=2009-11-13 16:28:10.406 ]: | |
The backend application (process 28845) did not send a valid HTTP response; instead, it sent nothing at all. It is possible that it has crashed; please check whether there are crashing bugs in this application. | |
*** Exception NoMethodError in PhusionPassenger::Rack::ApplicationSpawner (undefined method `[]' for nil:NilClass) (process 28845): | |
from /home/deploy/integrity/vendor/gems/gems/bobette-0.0.5/lib/bobette/github.rb:28:in `uri' | |
from /home/deploy/integrity/vendor/gems/gems/bobette-0.0.5/lib/bobette/github.rb:15:in `call' | |
from /home/deploy/integrity/vendor/gems/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `call' | |
from /home/deploy/integrity/vendor/gems/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each' | |
from /home/deploy/integrity/vendor/gems/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/rack/builder.rb:60:in `call' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/rack/request_handler.rb:95:in `process_request' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/rack/application_spawner.rb:118:in `run' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/rack/application_spawner.rb:69:in `spawn_application' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/utils.rb:183:in `safe_fork' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/rack/application_spawner.rb:62:in `spawn_application' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/rack/application_spawner.rb:45:in `spawn_application' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/spawn_manager.rb:159:in `spawn_application' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:352:in `__send__' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:352:in `main_loop' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously' | |
from /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/bin/passenger-spawn-server:61 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment