class DTK::Common::GritAdapter::ObjectAccess

Public Class Methods

new(repo_dir,branch=nil) click to toggle source
Calls superclass method
# File lib/grit_adapter/object_access.rb, line 20
def initialize(repo_dir,branch=nil)
  super
  @grit_index = @grit_repo.index
end

Public Instance Methods

add_or_replace_file(file_path,content) click to toggle source
# File lib/grit_adapter/object_access.rb, line 29
def add_or_replace_file(file_path,content)
  @grit_index.add(file_path,content)
end
commit(commit_msg) click to toggle source
# File lib/grit_adapter/object_access.rb, line 45
def commit(commit_msg)
  @grit_index.commit(commit_msg,@grit_repo.commits,nil,nil,@branch)
  git_command("write-tree".to_sym)
end
commit_context(commit_msg) { || ... } click to toggle source
# File lib/grit_adapter/object_access.rb, line 50
def commit_context(commit_msg,&block)
  read_tree()
  yield
  commit(commit_msg)
end
create_branch(new_branch) click to toggle source
# File lib/grit_adapter/object_access.rb, line 37
def create_branch(new_branch)
  if branches().include?(new_branch)
    raise Error.new("Branch (#{new_branch}) already exists")
  end
  commit_msg = "adding new branch (#{new_branch})"
  @grit_index.commit(commit_msg,@grit_repo.commits,nil,nil,new_branch)
end
delete_file(file_path) click to toggle source
# File lib/grit_adapter/object_access.rb, line 33
def delete_file(file_path)
  @grit_index.delete(file_path)
end
read_tree() click to toggle source
# File lib/grit_adapter/object_access.rb, line 25
def read_tree()
  @grit_index.read_tree(@branch)
end