# encoding: utf-8 module Mutx module Routes module Api module Git class Routes < App define do on get do on "pull" do result = Mutx::Database::MongoConnector.last_commit_webhook result_parsed = result["log"]["commits"].join.gsub('=>', ':') last = JSON.parse result_parsed #hash result = Mutx::Database::MongoConnector.before_last_commit_webhook result_parsed = result["log"]["commits"].join.gsub('=>', ':') before_last = JSON.parse result_parsed #hash output = {:last_commit => last, :before_last_commit => before_last} res.write output.to_json end end on post do on "pull" do #Check for updates on the branch and make a pull if its outdated ##Mutx::Support::Git.pull unless Mutx::Support::Git.up_to_date? data_json = JSON.parse req.body.read Mutx::Support::ChangeInspector.is_there_a_change? data_json Mutx::Support::Log.debug "#{data_json}" if Mutx::Support::Log Mutx::Support::Bundle.new.bundle_update if data_json["repository"]["language"].eql? "Ruby" res.status = 200 res.write "status 200" end end end end end end end end