Class: CodeClimate::TestReporter::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/code_climate/test_reporter/git.rb

Class Method Summary collapse

Class Method Details

.branch_from_git_or_ciObject



13
14
15
# File 'lib/code_climate/test_reporter/git.rb', line 13

def branch_from_git_or_ci
  clean_service_branch || clean_git_branch || "master"
end

.clean_git_branchObject



24
25
26
27
28
29
# File 'lib/code_climate/test_reporter/git.rb', line 24

def clean_git_branch
  git_branch = String(branch_from_git)
  clean = git_branch.sub(%r{^origin/}, "") unless git_branch.start_with?("(")

  !clean.empty? ? clean : nil
end

.clean_service_branchObject



17
18
19
20
21
22
# File 'lib/code_climate/test_reporter/git.rb', line 17

def clean_service_branch
  ci_branch = String(Ci.service_data[:branch])
  clean = ci_branch.strip.sub(%r{^origin/}, "")

  !clean.empty? ? clean : nil
end

.infoObject



5
6
7
8
9
10
11
# File 'lib/code_climate/test_reporter/git.rb', line 5

def info
  {
    head:         head,
    committed_at: committed_at,
    branch:       branch_from_git,
  }
end