class Git::DiffPathStatus

The files and their status (e.g., added, modified, deleted) between two commits

Public Class Methods

new(base, from, to, path_limiter = nil) click to toggle source

@private

# File lib/git/diff_path_status.rb, line 9
def initialize(base, from, to, path_limiter = nil)
  # Eagerly check for invalid arguments
  [from, to].compact.each do |arg|
    raise ArgumentError, "Invalid argument: '#{arg}'" if arg.start_with?('-')
  end

  @base = base
  @from = from
  @to = to
  @path_limiter = path_limiter
  @path_status = nil
end

Public Instance Methods

each(&) click to toggle source

Iterates over each file’s status.

@yield [path, status]

# File lib/git/diff_path_status.rb, line 25
def each(&)
  fetch_path_status.each(&)
end
to_h() click to toggle source

Returns the name-status report as a Hash.

@return [Hash<String, String>] A hash where keys are file paths

and values are their status codes.
# File lib/git/diff_path_status.rb, line 33
def to_h
  fetch_path_status
end

Private Instance Methods

fetch_path_status() click to toggle source

Lazily fetches and caches the path status from the git lib.

# File lib/git/diff_path_status.rb, line 40
def fetch_path_status
  @fetch_path_status ||= @base.lib.diff_path_status(
    @from, @to, { path: @path_limiter }
  )
end