File tree 2 files changed +5
-4
lines changed
lib/overcommit/hook_context
spec/overcommit/hook_context
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ def modified_files
17
17
# @return [Set]
18
18
def modified_lines_in_file ( file )
19
19
@modified_lines_in_file ||= { }
20
- @modified_lines_in_file [ file ] ||= Set . new ( 1 ..( count_lines ( file ) + 1 ) )
20
+ @modified_lines_in_file [ file ] ||= Set . new ( 1 ..count_lines ( file ) )
21
21
end
22
22
23
23
def hook_class_name
@@ -35,8 +35,9 @@ def hook_script_name
35
35
private
36
36
37
37
def count_lines ( file )
38
- result = Overcommit ::Utils . execute ( %w[ wc -l ] + [ file ] )
39
- result . success? ? result . stdout . to_i : 0
38
+ num_lines = 0
39
+ File . new ( file ) . each_line { num_lines += 1 }
40
+ num_lines
40
41
end
41
42
end
42
43
end
Original file line number Diff line number Diff line change 67
67
end
68
68
end
69
69
70
- it { should == Set . new ( 1 ..4 ) }
70
+ it { should == Set . new ( 1 ..3 ) }
71
71
end
72
72
73
73
context 'when file does not contain a trailing newline' do
You can’t perform that action at this time.
0 commit comments