MCPcopy Index your code
hub / github.com/nodegit/nodegit / commitFile

Function commitFile

test/tests/filter.js:26–74  ·  view source on GitHub ↗
(repo, fileName, fileContent, commitMessage)

Source from the content-addressed store, hash-verified

24 };
25
26 function commitFile(repo, fileName, fileContent, commitMessage) {
27 let index;
28 let treeOid;
29 let parent;
30
31 return fse.writeFile(path.join(repo.workdir(), fileName), fileContent)
32 .then(function() {
33 return repo.refreshIndex();
34 })
35 .then(function(indexResult) {
36 index = indexResult;
37 })
38 .then(function() {
39 return index.addByPath(fileName);
40 })
41 .then(function() {
42 return index.write();
43 })
44 .then(function() {
45 return index.writeTree();
46 })
47 .then(function(oidResult) {
48 treeOid = oidResult;
49 return NodeGit.Reference.nameToId(repo, "HEAD");
50 })
51 .then(function(head) {
52 return repo.getCommit(head);
53 })
54 .then(function(parentResult) {
55 parent = parentResult;
56 return Promise.all([
57 NodeGit.Signature.create("Foo Bar", "foo@bar.com", 123456789, 60),
58 NodeGit.Signature.create("Foo A Bar", "foo@bar.com", 987654321, 90)
59 ]);
60 })
61 .then(function(signatures) {
62 let author = signatures[0];
63 let committer = signatures[1];
64
65 return repo.createCommit(
66 "HEAD",
67 author,
68 committer,
69 commitMessage,
70 treeOid,
71 [parent]
72 );
73 });
74 }
75
76 beforeEach(function() {
77 var test = this;

Callers 1

filter.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…