Created
December 10, 2010 09:48
-
-
Save minhajuddin/736033 to your computer and use it in GitHub Desktop.
Post receive hook for git syncing
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 | |
class Sync | |
def initialize(gitpart) | |
@from, @to, @ref = gitpart.split | |
@branch = @ref.split('/').last | |
end | |
def exec | |
puts '---------- executing receive hook ----------' | |
case @branch | |
when "dev" | |
push "cv-mirror" | |
when "master" | |
push "cv-mirror" | |
push "github-mirror" | |
when "deploy" | |
push "cv-mirror" | |
push "github-mirror" | |
puts 'deploying to remote server' | |
end | |
puts '---------- executed receive hook ----------' | |
end | |
private | |
def push(remote) | |
puts ">>>>> pushing to #{@branch} to #{remote}" | |
op = `git push #{remote} #{@branch}` | |
puts op | |
puts ">>>>> pushed to #{@branch} to #{remote}" | |
end | |
end | |
Sync.new(ARGF.read).exec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment