(repo, fileName, fileContent, commitMessage)
| 17 | var previousCommitOid = ""; |
| 18 | |
| 19 | function commitFile(repo, fileName, fileContent, commitMessage) { |
| 20 | var index; |
| 21 | var treeOid; |
| 22 | var parent; |
| 23 | |
| 24 | return fse.writeFile(path.join(repo.workdir(), fileName), fileContent) |
| 25 | .then(function() { |
| 26 | return repo.refreshIndex(); |
| 27 | }) |
| 28 | .then(function(indexResult) { |
| 29 | index = indexResult; |
| 30 | }) |
| 31 | .then(function() { |
| 32 | return index.addByPath(fileName); |
| 33 | }) |
| 34 | .then(function() { |
| 35 | return index.write(); |
| 36 | }) |
| 37 | .then(function() { |
| 38 | return index.writeTree(); |
| 39 | }) |
| 40 | .then(function(oidResult) { |
| 41 | treeOid = oidResult; |
| 42 | return NodeGit.Reference.nameToId(repo, "HEAD"); |
| 43 | }) |
| 44 | .then(function(head) { |
| 45 | return repo.getCommit(head); |
| 46 | }) |
| 47 | .then(function(parentResult) { |
| 48 | parent = parentResult; |
| 49 | return Promise.all([ |
| 50 | NodeGit.Signature.create("Foo Bar", "foo@bar.com", 123456789, 60), |
| 51 | NodeGit.Signature.create("Foo A Bar", "foo@bar.com", 987654321, 90) |
| 52 | ]); |
| 53 | }) |
| 54 | .then(function(signatures) { |
| 55 | var author = signatures[0]; |
| 56 | var committer = signatures[1]; |
| 57 | |
| 58 | return repo.createCommit( |
| 59 | "HEAD", |
| 60 | author, |
| 61 | committer, |
| 62 | commitMessage, |
| 63 | treeOid, |
| 64 | [parent] |
| 65 | ); |
| 66 | }); |
| 67 | } |
| 68 | |
| 69 | before(function() { |
| 70 | return Repository.open(reposPath) |
no outgoing calls
no test coverage detected
searching dependent graphs…