Pro Git

Pro Git

🎯 ¿Cansado de los anuncios?
Elimínalos ahora 🚀
require 'httparty' require 'sinatra' require 'json' post '/payload' do push = JSON.parse(request.body.read) # parse the JSON repo_name = push['repository']['full_name'] # look through each commit message push["commits"].each do |commit| # look for a Signed-off-by string if /Signed-off-by/.match commit['message'] state = 'success' description = 'Successfully signed off!' else state = 'failure' description = 'No signoff found.' end # post status to GitHub sha = commit["id"] status_url = "https://api.github.com/repos/#{repo_name}/statuses/#{sha}" status = { "state" => state, "description" => description, "target_url" => "http://example.com/how-to-signoff", "context" => "validate/signoff" } HTTParty.post(status_url, :body => status.to_json, :headers => { 'Content-Type' => 'application/json', 'User-Agent' => 'tonychacon/signoff', 'Authorization' => "token #{ENV['TOKEN']}" } ) end end

Creemos que esto es fácil de seguir. En este controlador del enganche, miramos en cada “commit” enviado, y buscamos la cadena Signed-off-by en el mensaje de “commit”, y finalmente hacemos un HTTP POST al servicio de API /repos/<user>/<repo>/statuses/<commit_sha> con el resultado.


👉 Descargar el audiolibro GRATIS en Amazon
Reportar problema / Sugerencias
🧠 Hacer Trivia

eXTReMe Tracker