File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ class Patch
44 RANGE_INFORMATION_LINE = /^@@ .+\+ (?<line_number>\d +),/
55 MODIFIED_LINE = /^\+ (?!\+ |\+ )/
66 NOT_REMOVED_LINE = /^[^-]/
7+ NO_NEWLINE_MESSAGE = /^\\ No newline at end of file$/
78
89 attr_accessor :file , :body , :secure_hash
910 # @!attribute [rw] file
@@ -60,6 +61,8 @@ def changed_lines
6061 case content
6162 when RANGE_INFORMATION_LINE
6263 line_number = Regexp . last_match [ :line_number ] . to_i
64+ when NO_NEWLINE_MESSAGE
65+ # nop
6366 when MODIFIED_LINE
6467 line = Line . new (
6568 content : content ,
Original file line number Diff line number Diff line change @@ -39,6 +39,17 @@ module GitDiffParser
3939 end
4040 end
4141
42+ context "Newline inserted at EOF" do
43+ describe "changed_line_numbers" do
44+ it "returns changed line number" do
45+ patch_body = File . read ( 'spec/support/fixtures/file4.diff' )
46+ patch = Patch . new ( patch_body )
47+
48+ expect ( patch . changed_line_numbers ) . to eq [ 4 ]
49+ end
50+ end
51+ end
52+
4253 describe '#find_patch_position_by_line_number' do
4354 it 'returns patch position that were included' do
4455 patch_body = File . read ( 'spec/support/fixtures/patch.diff' )
Original file line number Diff line number Diff line change 1+ @@ -1,4 +1,4 @@
2+ 1
3+ 2
4+ 3
5+ - File1
6+ \ No newline at end of file
7+ + File1 v2
You can’t perform that action at this time.
0 commit comments