Class: Repository::Inspector
- Inherits:
-
Object
- Object
- Repository::Inspector
- Defined in:
- lib/repository/inspector.rb
Instance Method Summary collapse
- #compare_index_to_workspace(entry, stat) ⇒ Object
- #compare_tree_to_index(item, entry) ⇒ Object
-
#initialize(repository) ⇒ Inspector
constructor
A new instance of Inspector.
- #trackable_file?(path, stat) ⇒ Boolean
Constructor Details
#initialize(repository) ⇒ Inspector
Returns a new instance of Inspector.
4 5 6 |
# File 'lib/repository/inspector.rb', line 4 def initialize(repository) @repo = repository end |
Instance Method Details
#compare_index_to_workspace(entry, stat) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/repository/inspector.rb', line 23 def compare_index_to_workspace(entry, stat) return :untracked unless entry return :deleted unless stat return :modified unless entry.stat_match?(stat) return nil if entry.times_match?(stat) data = @repo.workspace.read_file(entry.path) blob = Database::Blob.new(data) oid = @repo.database.hash_object(blob) unless entry.oid == oid :modified end end |
#compare_tree_to_index(item, entry) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/repository/inspector.rb', line 38 def compare_tree_to_index(item, entry) return nil unless item or entry return :added unless item return :deleted unless entry unless entry.mode == item.mode and entry.oid == item.oid :modified end end |
#trackable_file?(path, stat) ⇒ Boolean
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/repository/inspector.rb', line 8 def trackable_file?(path, stat) return false unless stat return !@repo.index.tracked_file?(path) if stat.file? return false unless stat.directory? items = @repo.workspace.list_dir(path) files = items.select { |_, item_stat| item_stat.file? } dirs = items.select { |_, item_stat| item_stat.directory? } [files, dirs].any? do |list| list.any? { |item_path, item_stat| trackable_file?(item_path, item_stat) } end end |