Module: GitHubDiff
- Defined in:
- lib/diff-suggester/diff/diff.rb,
lib/diff-suggester/diff/hunk.rb,
lib/diff-suggester/diff/diff_parser.rb
Defined Under Namespace
Class Method Summary collapse
Class Method Details
.get_diff_string ⇒ Object
15 16 17 |
# File 'lib/diff-suggester/diff/diff_parser.rb', line 15 def get_diff_string return ::GitDiff.from_string(`git diff --unified=0 HEAD`) end |
.hunk(hunk) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/diff-suggester/diff/diff_parser.rb', line 19 def hunk(hunk) addition_lines = hunk.lines.select{|l| l.content.start_with?('+')}.map do |line| line.content.scan(/^\+([^+].*)/) end target_range = hunk.range_info.original_range return Hunk.new(body: addition_lines.join("\n"), start_line: target_range.start, end_line: target_range.start + target_range.number_of_lines) end |