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



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

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

.clean_git_branchObject



32
33
34
35
36
37
# File 'lib/code_climate/test_reporter/git.rb', line 32

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



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

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

  !clean.empty? ? clean : nil
end

.committed_at_from_git_or_ciObject



21
22
23
# File 'lib/code_climate/test_reporter/git.rb', line 21

def committed_at_from_git_or_ci
  committed_at_from_git || committed_at_from_ci
end

.head_from_git_or_ciObject



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

def head_from_git_or_ci
  head_from_git || head_from_ci
end

.infoObject



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

def info
  {
    head:         head_from_git_or_ci,
    committed_at: committed_at_from_git_or_ci,
    branch:       branch_from_git_or_ci,
  }
end