def self.git
hash = {}
Dir.chdir(root) do
hash[:head] = {
:id => ENV.fetch("GIT_ID", `git log -1 --pretty=format:'%H'`),
:author_name => ENV.fetch("GIT_AUTHOR_NAME", `git log -1 --pretty=format:'%aN'`),
:author_email => ENV.fetch("GIT_AUTHOR_EMAIL", `git log -1 --pretty=format:'%ae'`),
:committer_name => ENV.fetch("GIT_COMMITTER_NAME", `git log -1 --pretty=format:'%cN'`),
:committer_email => ENV.fetch("GIT_COMMITTER_EMAIL", `git log -1 --pretty=format:'%ce'`),
:message => ENV.fetch("GIT_MESSAGE", `git log -1 --pretty=format:'%s'`)
}
hash[:branch] = ENV.fetch("GIT_BRANCH", `git rev-parse --abbrev-ref HEAD`)
remotes = nil
begin
remotes = `git remote -v`.split(/\n/).map do |remote|
splits = remote.split(" ").compact
{:name => splits[0], :url => splits[1]}
end.uniq
rescue
end
hash[:remotes] = remotes
end
hash
rescue Exception => e
Coveralls::Output.puts "Coveralls git error:", :color => "red"
Coveralls::Output.puts e.to_s, :color => "red"
nil
end