(repo, fileName, fileContent, commitMessage)
| 33 | } |
| 34 | |
| 35 | function commitFile(repo, fileName, fileContent, commitMessage) { |
| 36 | var index; |
| 37 | var treeOid; |
| 38 | var parent; |
| 39 | |
| 40 | return fse.writeFile(path.join(repo.workdir(), fileName), fileContent) |
| 41 | .then(function() { |
| 42 | return repo.refreshIndex(); |
| 43 | }) |
| 44 | .then(function(indexResult) { |
| 45 | index = indexResult; |
| 46 | }) |
| 47 | .then(function() { |
| 48 | return index.addByPath(fileName); |
| 49 | }) |
| 50 | .then(function() { |
| 51 | return index.write(); |
| 52 | }) |
| 53 | .then(function() { |
| 54 | return index.writeTree(); |
| 55 | }) |
| 56 | .then(function(oidResult) { |
| 57 | treeOid = oidResult; |
| 58 | return NodeGit.Reference.nameToId(repo, "HEAD"); |
| 59 | }) |
| 60 | .then(function(head) { |
| 61 | return repo.getCommit(head); |
| 62 | }) |
| 63 | .then(function(parentResult) { |
| 64 | parent = parentResult; |
| 65 | return Promise.all([ |
| 66 | NodeGit.Signature.create("Foo Bar", "foo@bar.com", 123456789, 60), |
| 67 | NodeGit.Signature.create("Foo A Bar", "foo@bar.com", 987654321, 90) |
| 68 | ]); |
| 69 | }) |
| 70 | .then(function(signatures) { |
| 71 | var author = signatures[0]; |
| 72 | var committer = signatures[1]; |
| 73 | |
| 74 | return repo.createCommit( |
| 75 | "HEAD", |
| 76 | author, |
| 77 | committer, |
| 78 | "message", |
| 79 | treeOid, |
| 80 | [parent]); |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | function undoCommit() { |
| 85 | return exec("git reset --hard HEAD~1", {cwd: reposPath}); |
no outgoing calls
no test coverage detected
searching dependent graphs…