# File lib/code_climate/test_reporter/git.rb, line 14 def branch_from_git_or_ci clean_service_branch || clean_git_branch || "master" end
# File lib/code_climate/test_reporter/git.rb, line 25 def clean_git_branch git_branch = String(branch_from_git) clean = git_branch.sub(/^origin\//, "") unless git_branch.start_with?("(") clean.size > 0 ? clean : nil end
# File lib/code_climate/test_reporter/git.rb, line 18 def clean_service_branch ci_branch = String(Ci.service_data[:branch]) clean = ci_branch.strip.sub(/^origin\//, "") clean.size > 0 ? clean : nil end
# File lib/code_climate/test_reporter/git.rb, line 6 def info { head: head, committed_at: committed_at, branch: branch_from_git, } end
# File lib/code_climate/test_reporter/git.rb, line 43 def branch_from_git git('rev-parse --abbrev-ref HEAD').chomp end
# File lib/code_climate/test_reporter/git.rb, line 38 def committed_at committed_at = git('log -1 --pretty=format:%ct') committed_at.to_i.zero? ? nil : committed_at.to_i end
# File lib/code_climate/test_reporter/git.rb, line 56 def configured_git_dir CodeClimate::TestReporter.configuration.git_dir end
# File lib/code_climate/test_reporter/git.rb, line 47 def git(command) %xgit --git-dir=#{git_dir}/.git #{command}` end
# File lib/code_climate/test_reporter/git.rb, line 51 def git_dir return configured_git_dir unless configured_git_dir.nil? rails_git_dir_present? ? Rails.root : '.' end
# File lib/code_climate/test_reporter/git.rb, line 34 def head git("log -1 --pretty=format:'%H'") end
# File lib/code_climate/test_reporter/git.rb, line 60 def rails_git_dir_present? defined?(Rails) && !Rails.root.nil? && File.directory?(File.expand_path('.git', Rails.root)) end