Skip to content

How to create the tree for creating a commit? #37

Open
@iamwilhelm

Description

@iamwilhelm

I'm able to create a Blob, and I see a repository.createCommit call, which requires you to pass in a Tree. However, how do you create the tree for a commit? The createTree() call is not yet implemented.

However, I assume I should be able to do it by hand. And yet, I don't have access to the TreeEntry object to stuff the Blob object into. I also don't seem to have access to Signature for the commit as well. I assume it should look something like (in coffeescript):

repo = gitteh.openRepository('some/path.git')
refHead = repo.getReference('HEAD').resolve()

blob = repo.createBlob({ data: new Buffer("some data") })

// how to access TreeEntry?
treeEntry = new gitteh.TreeEntry({ name: "blob.txt", id: blob.id })

tree = new gitteh.Tree({ entries: [treeEntry] })

// how to get Signature?
commit = repo.createCommit({
  author: new gitteh.Signature({ name: "wil", email: "[email protected]" })
  parents: [refHead.target]
  message: "some commit message"
  tree: tree
})

And also, this seems like you have to recreate the entire tree in order to commit. That seems like a pain given that usually you just want to commit changed files. How do you commit changed files?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions