File tree 2 files changed +8
-4
lines changed
lib/code_climate/test_reporter 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ def initialize(file_path)
8
8
end
9
9
10
10
def blob_id
11
- calculate_with_file || calculate_with_git
11
+ calculate_with_file or calculate_with_git
12
12
end
13
13
14
14
private
@@ -22,10 +22,15 @@ def calculate_with_file
22
22
return Digest ::SHA1 . hexdigest ( store )
23
23
end
24
24
rescue EncodingError
25
+ puts "WARNING: Unable to read #{ @file_path } \n Using git for blob calculation"
26
+ nil
25
27
end
26
28
27
29
def calculate_with_git
28
- Kernel . system ( "git hash-object -t blob #{ @file_path } " )
30
+ output = `git hash-object -t blob #{ @file_path } ` . chomp
31
+ raise 'ERROR: Failed to calculate blob with git' unless $?. success?
32
+
33
+ output
29
34
end
30
35
31
36
end
Original file line number Diff line number Diff line change @@ -17,8 +17,7 @@ module CodeClimate::TestReporter
17
17
18
18
it 'falls back to git' do
19
19
expect ( File ) . to receive ( :open ) . and_raise ( EncodingError )
20
- expect ( Kernel ) . to receive ( :system ) . with ( "git hash-object -t blob #{ fixture } " ) . and_return ( '123' )
21
- expect ( subject . blob_id ) . to eq ( '123' )
20
+ expect ( subject . blob_id ) . to eq ( 'eb82c22dadb9c47a7fed87211623f6856e112f46' )
22
21
end
23
22
24
23
end
You can’t perform that action at this time.
0 commit comments