FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fixes #852 should not be an array with null in it by josh-shaw-dev · Pull Request #927 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion lib/repository.js
This file contains hidden or 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
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,16 @@ Repository.prototype.createCommitOnHead = function(
.then(function(treeOid) {
return repo.getHeadCommit()
.then(function(parent) {
if (parent !== null) { // To handle a fresh repo with no commits
parent = [parent];
}
return repo.createCommit(
"HEAD",
author,
committer,
message,
treeOid,
[parent]
parent
);
});
}, callback);
Expand Down
29 changes: 29 additions & 0 deletions test/tests/repository.js
This file contains hidden or 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
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,33 @@ describe("Repository", function() {
assert(!commit);
});
});

it("can commit on head on a empty repo with createCommitOnHead", function() {
var fileName = "my-new-file-that-shouldnt-exist.file";
var fileContent = "new file from repository test";
var repo = this.emptyRepo;
var filePath = path.join(repo.workdir(), fileName);
var authSig = repo.defaultSignature();
var commitSig = repo.defaultSignature();
var commitMsg = "Doug this has been commited";

return fse.writeFile(filePath, fileContent)
.then(function() {
return repo.createCommitOnHead(
[filePath],
authSig,
commitSig,
commitMsg
);
})
.then(function(oidResult) {
return repo.getHeadCommit()
.then(function(commit) {
assert.equal(
commit.toString(),
oidResult.toString()
);
});
});
});
});

Back | FazBrowse Home | New Git URL