File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
lib/code_climate/test_reporter
spec/code_climate/test_reporter Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ def info
10
10
}
11
11
end
12
12
13
+ def head_from_git_or_ci
14
+ head_from_git || head_from_ci
15
+ end
16
+
13
17
def branch_from_git_or_ci
14
18
clean_service_branch || clean_git_branch || "master"
15
19
end
@@ -34,10 +38,6 @@ def clean_git_branch
34
38
35
39
private
36
40
37
- def head_from_git_or_ci
38
- head_from_git || head_from_ci
39
- end
40
-
41
41
def head_from_git
42
42
commit_hash = git ( "log -1 --pretty=format:'%H'" )
43
43
!commit_hash . empty? ? commit_hash : nil
Original file line number Diff line number Diff line change @@ -79,6 +79,21 @@ def self.root
79
79
end
80
80
end
81
81
82
+ describe 'head_from_git_or_ci' do
83
+ it 'returns the head sha from git' do
84
+ expect ( Git ) . to receive ( :git ) . with ( "log -1 --pretty=format:'%H'" ) . and_return ( "1234" )
85
+
86
+ expect ( Git . head_from_git_or_ci ) . to eq '1234'
87
+ end
88
+
89
+ it 'returns the head sha from ci if git is not available' do
90
+ expect ( Git ) . to receive ( :git ) . with ( "log -1 --pretty=format:'%H'" ) . and_return ( "" )
91
+ expect ( Ci ) . to receive ( :service_data ) . and_return ( { commit_sha : "4567" } )
92
+
93
+ expect ( Git . head_from_git_or_ci ) . to eq '4567'
94
+ end
95
+ end
96
+
82
97
describe 'committed_at_from_git_or_ci' do
83
98
it 'returns the committed_at from git' do
84
99
expect ( Git . committed_at_from_git_or_ci ) . to eq Git . send ( :committed_at_from_git )
You can’t perform that action at this time.
0 commit comments