Created
January 16, 2009 14:57
-
-
Save djanowski/47947 to your computer and use it in GitHub Desktop.
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 | |
# Usage: | |
# | |
# $ build.rb http://yoururl.com/your_project/push | |
# | |
# $ echo "HEAD -1 refs/heads/master" | build.rb http://yoururl.com/your_project/push | |
# | |
# or you can hard-code the URL in the following line instead | |
# of passing it as an argument. | |
url = ARGV.pop | |
####################################################################### | |
## ## | |
## == 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 unless $stdin.tty? | |
old_head = old_head ? "^#{old_head}" : "-1" | |
new_head ||= "HEAD" | |
ref ||= "refs/heads/master" | |
revisions = `git rev-list --pretty=oneline #{new_head} #{old_head} | awk '{print $1}'`.split("\n") | |
revisions.map! {|r| %Q({"id":"#{r}"}) }.join(",") | |
payload = %Q({"ref":"#{ref}", "commits":[#{revisions}]}) | |
puts Net::HTTP.post_form(URI.parse(url), { | |
:payload => payload | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment