Skip to content

Instantly share code, notes, and snippets.

@foca foca/post-receive Secret
Created Nov 17, 2008

Embed
What would you like to do?
Generic Integrity post-receive-hook for non-github repos
#!/usr/local/bin/ruby
# Replace the following by the url given to you in your project's edit page
POST_RECEIVE_URL = 'http://localhost:4567/my_fancy_project/push'
#######################################################################
## ##
## == DON'T EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING == ##
## ##
#######################################################################
require 'net/http'
require 'uri'
old_head, new_head, ref = STDIN.gets.split
revisions = `git-rev-list --pretty=oneline #{new_head} ^#{old_head} | awk '{print $1}'`.split("\n")
revisions.map! {|r| %Q({"id":"#{r}"}) }.join(",")
Net::HTTP.post_form(URI.parse(POST_RECEIVE_URL), {
:payload => %Q({"ref":"#{ref}", "commits":[#{revisions}]})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.