Created
October 14, 2009 17:32
-
-
Save rich/210239 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
module BeanstalkPushSupport | |
def push(payload) | |
return super unless from_beanstalk?(payload) | |
payload = parse_payload(payload) | |
commit = commits.new( | |
:identifier => payload['revision'], | |
:author => "#{payload['author_full_name']} <#{payload['author_email']}>", | |
:message => payload['message'], | |
:committed_at => payload['time'] | |
) | |
commit.create | |
build(commit.identifier) | |
end | |
def from_beanstalk?(payload) | |
payload =~ /changeset_url/i && payload =~ /beanstalkapp/i | |
end | |
end | |
Integrity::Project.send(:include, BeanstalkPushSupport) | |
class Integrity::App | |
post "/:project/beanstalk_push" do | |
login_required | |
content_type "text/plain" | |
begin | |
current_project.push(params[:commit]) | |
201 | |
rescue ArgumentError | |
[422, "Invalid Request"] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment