class FakeGit::CommitTree

Public Instance Methods

call(*args) click to toggle source
# File lib/fake_git/commit_tree.rb, line 6
def call(*args)
  # make sure that the object exists
  obj = FakeGit::FetchObject.new.call(args.first)

  raise TypeError.new("#{args.first} is not a tree") if obj.type != "tree"

  commit = FakeGit::Priv::Object.new(
    type: "commit",
    message: $OPTIONS[:commit_message],
    tree: obj.index,
    index: Digest::SHA1.hexdigest(obj.index), # just hash the index of the tree
  )

  commit.write!
  FakeGit::UpdateRef.new.call(commit.index)
end