-
-
Save foca/e431699c726fd17fb06a to your computer and use it in GitHub Desktop.
Generic Integrity post-receive-hook for non-github repos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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