Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@
}
},
"git_index_new": {
"ignore": true
"isAsync": false
},
"git_index_read": {
"args": {
Expand Down
23 changes: 23 additions & 0 deletions test/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@ describe("Index", function() {
NodeGit.disableThreadSafety();
});

it("can create a new index and add entries", function(){

var index = NodeGit.Index.create();
//create file entry
var fileContent = new Buffer("first file content", "binary");
var newFileOid = NodeGit.Blob.createFromBuffer(this.repository,
fileContent,
fileContent.length);
var fileEntry = new NodeGit.IndexEntry();
fileEntry.path = "sub/folder/firstfile.txt";
fileEntry.id = newFileOid;
fileEntry.mode = NodeGit.TreeEntry.FILEMODE.BLOB;
fileEntry.ctime.seconds = new Date().getTime();
fileEntry.mtime.seconds = new Date().getTime();
//add entry to index
index.add(fileEntry);
//check index has entry
assert.equal(1, index.entries().length, "Index should contain entry");
//check for conflicts, which there of course should definitely not be
// considering this is a new index, and we've only added 1 entry
assert.equal(false,index.hasConflicts(), "Index should not have conflicts");
});

it("can get the index of a repo and examine entries", function() {
var entries = this.index.entries();

Expand Down