Created
July 16, 2010 20:03
-
-
Save ryanflorence/478846 to your computer and use it in GitHub Desktop.
Ruby Git post-receive hook to parse out the stdin and assign them to variables
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/bin/env ruby | |
# figure out which repository this is | |
# assumes it's a bare repository | |
repository = /([^\/]*?)\.git$/.match(`pwd`.chomp)[1] | |
# get the stdins from git | |
stdins = []; stdins << $_ while gets | |
stdins.each do |str| | |
# parse the stdin string | |
arr = str.split | |
refs = arr[2].split('/') | |
# what we're really after | |
oldrev = arr[0] # SHA | |
newrev = arr[1] # SHA | |
ref_type = refs[1] # tags || heads (branch) | |
ref_name = refs[2] # develop, 1.4 etc. | |
# now do whatcha gotta do | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! It helped me create an integration with Pivotal Tracker: https://gist.github.com/895521