File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module GitDiffParser
33 class Patch
44 RANGE_INFORMATION_LINE = /^@@ .+\+ (?<line_number>\d +),/
55 MODIFIED_LINE = /^\+ (?!\+ |\+ )/
6+ REMOVED_LINE = /^[-]/
67 NOT_REMOVED_LINE = /^[^-]/
78
89 attr_accessor :file , :body , :secure_hash
@@ -76,6 +77,27 @@ def changed_lines
7677 end
7778 end
7879
80+ def removed_lines
81+ line_number = 0
82+
83+ lines . each_with_index . inject ( [ ] ) do |lines , ( content , patch_position ) |
84+ case content
85+ when RANGE_INFORMATION_LINE
86+ line_number = Regexp . last_match [ :line_number ] . to_i
87+ when REMOVED_LINE
88+ line = Line . new (
89+ content : content ,
90+ number : line_number ,
91+ patch_position : patch_position
92+ )
93+ lines << line
94+ line_number += 1
95+ end
96+
97+ lines
98+ end
99+ end
100+
79101 # @return [Array<Integer>] changed line numbers
80102 def changed_line_numbers
81103 changed_lines . map ( &:number )
You can’t perform that action at this time.
0 commit comments