Skip to content

Instantly share code, notes, and snippets.

@mkaito
Created July 27, 2012 02:49
Show Gist options
  • Save mkaito/3185932 to your computer and use it in GitHub Desktop.
Save mkaito/3185932 to your computer and use it in GitHub Desktop.
post-receive hook to notify our hubot instance
#!/usr/bin/env ruby
# Notify hubot when someone pushes.
require 'net/http'
branches = []
cnum = 0
STDIN.each do |line|
(oldref, newref, refname) = line.split
branches.push `git rev-parse --symbolic --abbrev-ref #{refname}`.chomp
cnum += `git log --format=oneline #{oldref}..#{newref} | wc -l`.chomp
end
branches = branches.uniq.join(", ")
repo = ENV['GL_REPO']
user = ENV['GL_USER']
uri = URI('http://memorici.de:54545/hubot/git/pushed/spaceships/')
Net::HTTP.post_form uri, 'user' => user, 'num' => cnum, 'branch' => branches, 'repo' => repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment