Skip to content

Instantly share code, notes, and snippets.

@richievos
Created September 1, 2009 03:03
Show Gist options
  • Save richievos/178873 to your computer and use it in GitHub Desktop.
Save richievos/178873 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'json'
require 'yaml'
require 'highline/import'
require File.dirname(__FILE__) + '/../lib/coop/status'
cred_info = if File.exist?('config/coop-creds.yml')
YAML.load(File.read('config/coop-creds.yml'))
else
{}
end
[Coop::Status, Coop::Group].each do |resource|
resource.user = cred_info['username'] || ask("Enter your username: ") { |q| q.echo = true }
resource.password = cred_info['password'] || ask("Enter your password: ") { |q| q.echo = "*" }
end
group_id = cred_info['group_id'] || ask("Enter the group id to update: ") { |q| q.echo = true }
get '/coop-hook/version' do
@revision ||= File.exist?('REVISION') ? File.read('REVISION') : 'unknown'
end
post '/coop-hook' do
push = JSON.parse(params[:payload])
push['commits'].each do |commit|
Coop::Status.from_github_commit_info(group_id, commit).save
end
"Thanks for playing"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment