Skip to content

Instantly share code, notes, and snippets.

@tekkub
Created November 18, 2009 21:54
Show Gist options
  • Save tekkub/238305 to your computer and use it in GitHub Desktop.
Save tekkub/238305 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'net/http'
require 'net/https'
user = `git config --global github.user`.strip
token = `git config --global github.token`.strip
raise "Error reading github auth" if user.empty? || token.empty?
auth = {:login => user, :token => token}
projname = Dir.getwd.split("/").last
url = URI.parse "https://github.com/tekkub/#{projname.downcase}/edit/postreceive_urls"
req = Net::HTTP::Post.new(url.path)
req.set_form_data({"urls[]" => "http://tekkub.net/github"}.merge(auth), '&')
server = Net::HTTP.new url.host, url.port
server.use_ssl = url.scheme == 'https'
server.verify_mode = OpenSSL::SSL::VERIFY_NONE
res = server.start {|http| http.request(req) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment