Class: GitStore::FileStore
Overview
FileStore reads a working copy out of a directory. Changes made to the store will not be written to a repository. This is useful, if you want to read a filesystem without having a git repository.
Constant Summary
Constants inherited from GitStore
Handler, PACK_IDX_SIGNATURE, PACK_SIGNATURE
Instance Attribute Summary
Attributes inherited from GitStore
#branch, #head, #index, #lock_file, #path, #root
Instance Method Summary collapse
- #commit(message = "") ⇒ Object
- #each_blob_in(tree, &blob) ⇒ Object
-
#initialize(path) ⇒ FileStore
constructor
A new instance of FileStore.
- #load ⇒ Object
- #refresh! ⇒ Object
Methods inherited from GitStore
#[], #[]=, #changed?, #delete, #each, #finish_transaction, #get_object, #get_object_from_pack, #head_path, #in_transaction?, #inspect, #legacy_loose_object?, #load_packs, #object_path, #put_object, #read_head, #rollback, #sha, #start_transaction, #to_hash, #transaction
Constructor Details
#initialize(path) ⇒ FileStore
Returns a new instance of FileStore.
278 279 280 281 |
# File 'lib/git_store.rb', line 278 def initialize(path) @mtime = {} super end |
Instance Method Details
#commit(message = "") ⇒ Object
315 316 |
# File 'lib/git_store.rb', line 315 def commit(="") end |
#each_blob_in(tree, &blob) ⇒ Object
291 292 293 294 295 296 297 298 |
# File 'lib/git_store.rb', line 291 def each_blob_in(tree, &blob) tree.table.each do |name, entry| case entry when Blob; yield entry when Tree; each_blob_in(entry, &blob) end end end |
#load ⇒ Object
283 284 285 286 287 288 289 |
# File 'lib/git_store.rb', line 283 def load root.load_from_disk each_blob_in(root) do |blob| @mtime[blob.path] = File.mtime("#{path}/#{blob.path}") end end |
#refresh! ⇒ Object
300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/git_store.rb', line 300 def refresh! each_blob_in(root) do |blob| path = "#{self.path}/#{blob.path}" if File.exist?(path) mtime = File.mtime(path) if @mtime[blob.path] != mtime @mtime[blob.path] = mtime blob.load_from_disk end else delete blob.path end end end |