class Git::Status::Git::Status::StatusFileFactory
A factory class responsible for fetching git status data and building a hash of StatusFile
objects. @api private
Public Class Methods
Source
# File lib/git/status.rb, line 121 def initialize(base) @base = base @lib = base.lib end
Public Instance Methods
Source
# File lib/git/status.rb, line 128 def construct_files files_data = fetch_all_files_data files_data.transform_values do |data| StatusFile.new(@base, data) end end
Gathers all status data and builds a hash of file paths to StatusFile
objects.
Private Instance Methods
Source
# File lib/git/status.rb, line 138 def fetch_all_files_data files = @lib.ls_files # Start with files tracked in the index. merge_untracked_files(files) merge_modified_files(files) merge_head_diffs(files) files end
Fetches and merges status information from multiple git commands.
Source
# File lib/git/status.rb, line 159 def merge_head_diffs(files) return if @lib.empty? # Merge changes between HEAD and the index. @lib.diff_index('HEAD').each do |path, data| (files[path] ||= {}).merge!(data) end end
Source
# File lib/git/status.rb, line 152 def merge_modified_files(files) # Merge changes between the index and the working directory. @lib.diff_files.each do |path, data| (files[path] ||= {}).merge!(data) end end
Source
# File lib/git/status.rb, line 146 def merge_untracked_files(files) @lib.untracked_files.each do |file| files[file] = { path: file, untracked: true } end end