Created
October 12, 2018 16:05
-
-
Save thedanielhanke/430c61258c4f7e2162459678dacf89ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
//given: | |
const repo - bare Repository {} | |
const branchCommit = repo.getBranchCommit(branchName), | |
// actual method: | |
open: async (fn) => { | |
const tree = await branchCommit.getTree(); | |
const treeBuilder = await nodegit.Treebuilder.create(repo, tree); | |
const write = async (fileName, body) => { | |
const buffer = Buffer.from(body, 'UTF-8'); | |
const oid = await nodegit.Blob.createFromBuffer(repo, buffer, buffer.length); | |
await treeBuilder.insert(fileName, oid, 33188); | |
}; | |
await fn({ write }); | |
const id = await treeBuilder.write(); | |
return id; | |
}, | |
//.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment