Class: Gollum::Git::Index
- Inherits:
-
Object
- Object
- Gollum::Git::Index
- Defined in:
- lib/rugged_adapter/git_layer_rugged.rb
Instance Method Summary collapse
- #add(path, data) ⇒ Object
- #commit(message, parents = nil, actor = nil, last_tree = nil, head = 'refs/heads/master') ⇒ Object
- #current_tree ⇒ Object
- #delete(path) ⇒ Object
- #index ⇒ Object
-
#initialize(index, repo) ⇒ Index
constructor
A new instance of Index.
- #read_tree(id) ⇒ Object
- #tree ⇒ Object
Constructor Details
#initialize(index, repo) ⇒ Index
Returns a new instance of Index.
459 460 461 462 463 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 459 def initialize(index, repo) @index = index @rugged_repo = repo @treemap = {} end |
Instance Method Details
#add(path, data) ⇒ Object
471 472 473 474 475 476 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 471 def add(path, data) blob = @rugged_repo.write(data, :blob) @index.add(:path => path, :oid => blob, :mode => 0100644) update_treemap(path, data) data end |
#commit(message, parents = nil, actor = nil, last_tree = nil, head = 'refs/heads/master') ⇒ Object
482 483 484 485 486 487 488 489 490 491 492 493 494 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 482 def commit(, parents = nil, actor = nil, last_tree = nil, head = 'refs/heads/master') = {} head = "refs/heads/#{head}" unless head =~ /^refs\/heads\// parents = get_parents(parents, head) || [] actor = Gollum::Git::Actor.default_actor if actor.nil? [:tree] = @index.write_tree [:author] = actor.to_h [:committer] = actor.to_h [:message] = .to_s [:parents] = parents [:update_ref] = head Rugged::Commit.create(@rugged_repo, ) end |
#current_tree ⇒ Object
513 514 515 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 513 def current_tree @current_tree end |
#delete(path) ⇒ Object
465 466 467 468 469 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 465 def delete(path) @index.remove_all(path) update_treemap(path, false) false end |
#index ⇒ Object
478 479 480 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 478 def index @index end |
#read_tree(id) ⇒ Object
500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 500 def read_tree(id) id = Gollum::Git::Git.new(@rugged_repo).ref_to_sha(id) return nil if id.nil? begin current_tree = @rugged_repo.lookup(id) current_tree = current_tree.tree unless current_tree.is_a?(Rugged::Tree) @index.read_tree(current_tree) rescue raise Gollum::Git::NoSuchShaFound end @current_tree = Gollum::Git::Tree.new(current_tree) end |
#tree ⇒ Object
496 497 498 |
# File 'lib/rugged_adapter/git_layer_rugged.rb', line 496 def tree @treemap end |