Skip to content

Instantly share code, notes, and snippets.

@rich
Created October 14, 2009 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rich/210239 to your computer and use it in GitHub Desktop.
Save rich/210239 to your computer and use it in GitHub Desktop.
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