Class: Git::Diff::FullDiffParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/git/diff.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Private parser for git diff output

Examples:

Parse a diff patch

parser = Git::Diff::FullDiffParser.new(base, patch_text)
files = parser.parse

Instance Method Summary collapse

Constructor Details

#initialize(base, patch_text)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a new FullDiffParser

Parameters:



411
412
413
414
415
416
417
# File 'lib/git/diff.rb', line 411

def initialize(base, patch_text)
  @base = base
  @patch_text = patch_text
  @final_files = {}
  @current_file_data = nil
  @defaults = { mode: '', src: '', dst: '', type: 'modified', binary: false }
end

Instance Method Details

#parseArray<Array(String, Git::Diff::DiffFile)>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parses the diff text into a list of filename/DiffFile pairs

Returns:



424
425
426
427
# File 'lib/git/diff.rb', line 424

def parse
  @patch_text.split("\n").each { |line| process_line(line) }
  @final_files.map { |filename, data| [filename, DiffFile.new(@base, data)] }
end