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

Make index methods async by johnhaley81 · Pull Request #971 · 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  (14) .json  (1) All 2 file types 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
28 changes: 18 additions & 10 deletions examples/merge-cleanly.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 @@ -46,10 +46,13 @@ fse.remove(path.resolve(__dirname, repoDir))
return repository.refreshIndex();
})
.then(function(index) {
index.addByPath(ourFileName);
index.write();

return index.writeTree();
return index.addByPath(ourFileName)
.then(function() {
return index.write();
})
.then(function() {
return index.writeTree();
});
})
.then(function(oid) {
return repository.createCommit("HEAD", ourSignature,
Expand Down Expand Up @@ -81,10 +84,13 @@ fse.remove(path.resolve(__dirname, repoDir))
return repository.refreshIndex();
})
.then(function(index) {
index.addByPath(theirFileName);
index.write();

return index.writeTree();
return index.addByPath(theirFileName)
.then(function() {
return index.write();
})
.then(function() {
return index.writeTree();
});
})
.then(function(oid) {
// You don"t have to change head to make a commit to a different branch.
Expand All @@ -110,8 +116,10 @@ fse.remove(path.resolve(__dirname, repoDir))
// the repository instead of just writing it.
.then(function(index) {
if (!index.hasConflicts()) {
index.write();
return index.writeTreeTo(repository);
return index.write()
.then(function() {
return index.writeTreeTo(repository);
});
}
})

Expand Down
51 changes: 32 additions & 19 deletions examples/merge-with-conflicts.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 @@ -52,10 +52,13 @@ fse.remove(path.resolve(__dirname, repoDir))
return repository.refreshIndex();
})
.then(function(index) {
index.addByPath(fileName);
index.write();

return index.writeTree();
return index.addByPath(fileName)
.then(function() {
return index.write();
})
.then(function() {
return index.writeTree();
});
})
.then(function(oid) {
return repository.createCommit("HEAD", baseSignature,
Expand Down Expand Up @@ -95,10 +98,13 @@ fse.remove(path.resolve(__dirname, repoDir))
.then(function() {
return repository.refreshIndex()
.then(function(index) {
index.addByPath(fileName);
index.write();

return index.writeTree();
return index.addByPath(fileName)
.then(function() {
return index.write();
})
.then(function() {
return index.writeTree();
});
});
})
.then(function(oid) {
Expand All @@ -120,11 +126,15 @@ fse.remove(path.resolve(__dirname, repoDir))
);
})
.then(function() {
return repository.refreshIndex().then(function(index) {
index.addByPath(fileName);
index.write();

return index.writeTree();
return repository.refreshIndex()
.then(function(index) {
return index.addByPath(fileName)
.then(function() {
return index.write();
})
.then(function() {
return index.writeTree();
});
});
})
.then(function(oid) {
Expand Down Expand Up @@ -170,12 +180,15 @@ fse.remove(path.resolve(__dirname, repoDir))
// we need to get a new index as the other one isnt backed to
// the repository in the usual fashion, and just behaves weirdly
.then(function() {
return repository.refreshIndex().then(function(index) {

index.addByPath(fileName);
index.write();

return index.writeTree();
return repository.refreshIndex()
.then(function(index) {
return index.addByPath(fileName)
.then(function() {
return index.write();
})
.then(function() {
return index.writeTree();
});
});
})
.then(function(oid) {
Expand Down
11 changes: 7 additions & 4 deletions examples/push.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 @@ -33,10 +33,13 @@ fse.remove(path.resolve(__dirname, repoDir))
return repository.refreshIndex();
})
.then(function(index) {
index.addByPath(fileName);
index.write();

return index.writeTree();
return index.addByPath(fileName)
.then(function() {
return index.write();
})
.then(function() {
return index.writeTree();
});
})
.then(function(oid) {
return repository.createCommit("HEAD", signature, signature,
Expand Down
4 changes: 3 additions & 1 deletion examples/remove-and-commit.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 @@ -24,7 +24,9 @@ nodegit.Repository.open(path.resolve(__dirname, "../.git"))
})
.then(function() {
//remove the file from the index...
_index.removeByPath(fileName);
return _index.removeByPath(fileName);
})
.then(function() {
return _index.write();
})
.then(function() {
Expand Down
90 changes: 88 additions & 2 deletions generate/input/descriptor.json
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 @@ -959,6 +959,12 @@
},
"index": {
"functions": {
"git_index_add": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_add_all": {
"args": {
"pathspec": {
Expand All @@ -976,11 +982,34 @@
"isErrorCode": true
}
},
"git_index_add_bypath": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_add_frombuffer": {
"ignore": true
},
"git_index_conflict_get": {
"git_index_clear": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_conflict_add": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_conflict_cleanup": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_conflict_get": {
"args": {
"ancestor_out": {
"isReturn": true
Expand All @@ -992,6 +1021,7 @@
"isReturn": true
}
},
"isAsync": true,
"return": {
"isErrorCode": true
}
Expand All @@ -1005,6 +1035,12 @@
"git_index_conflict_next": {
"ignore": true
},
"git_index_conflict_remove": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_entrycount": {
"jsFunctionName": "entryCount"
},
Expand All @@ -1024,11 +1060,33 @@
"git_index_new": {
"ignore": true
},
"git_index_open": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_read": {
"args": {
"force": {
"isOptional": true
}
},
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_read_tree": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_remove": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_remove_all": {
Expand All @@ -1048,6 +1106,18 @@
"isErrorCode": true
}
},
"git_index_remove_bypath": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_remove_directory": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_update_all": {
"args": {
"pathspec": {
Expand All @@ -1070,7 +1140,23 @@
"force": {
"isOptional": true
}
}
},
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_write_tree": {
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_index_write_tree_to": {
"isAsync": true,
"return": {
"isErrorCode": true
}
}
},
"dependencies": [
Expand Down
Loading

Back | FazBrowse Home | New Git URL