ruby git hook

require 'webrick'
require 'json'
server = WEBrick::HTTPServer.new(:Port => ARGV.first)
server.mount_proc '/' do |req, res|
  # puts req.body
  body = JSON.parse(req.body)
  p body['commits'].first['message']
  if body['ref'].include?('master') && body['commits'].first['message'].include?('push-191')
     # system 'sh ~/git_deploy.sh'
     puts "========"
  end
  res.body = 'ok'
end
trap 'INT' do
  server.shutdown
end
server.start

你可能感兴趣的:(git,Ruby,hook)