class Kamaze::Project::Tools::Git::Status::Index
Represent index status
Public Instance Methods
safe?()
click to toggle source
Denote index is safe
Unsafe index shares modifications with the worktree, thus, files SHOULD NOT be naively analyzed, for example, by running a static code analysis. Running a static code analysis on unsafe index files COULD lead to inconsistent results.
@return [Boolean]
# File lib/kamaze/project/tools/git/status/index.rb, line 33 def safe? unsafe_files.empty? end
safe_files()
click to toggle source
Get files present in index and considered as safe
Safe files SHOULD NOT present divergent modifications between index and worktree. As seen in “unsafe_files“ only the modified state is considered.
# File lib/kamaze/project/tools/git/status/index.rb, line 60 def safe_files unsafe = self.unsafe_files.map { |f| f.absolute_path.to_s } self.to_a .reject { |f| unsafe.include?(f.absolute_path.to_s) } end
unsafe?()
click to toggle source
@return [Boolean]
# File lib/kamaze/project/tools/git/status/index.rb, line 38 def unsafe? !safe? end
unsafe_files()
click to toggle source
Get present files in intersection between index and worktree
@return [Array<File>]
# File lib/kamaze/project/tools/git/status/index.rb, line 45 def unsafe_files c = [self, worktree].map do |a| a.map { |f| f.absolute_path.to_s } end.freeze self.to_a.keep_if do |f| (c[0] & c[1]).include?(f.absolute_path.to_s) end end
Protected Instance Methods
worktree()
click to toggle source
Get a fresh (not frozen) copy of worktree as seen on initialization
@return [Kamaze::Project::Tools::Git::Status::Worktree]
# File lib/kamaze/project/tools/git/status/index.rb, line 72 def worktree memo = Array.new(memento) Kamaze::Project::Tools::Git::Status::Worktree.new(memo) end