Browse files

Merge pull request #1079 from novalis/dturner/tree-entry-by-name

fix Tree#entryByName function and add test
  • Loading branch information...
2 parents 7cfcf99 + 63f835e commit 1bfe672517f3f41f8b61cad98fe7e8bdb67f98a3 @tbranyen tbranyen committed on GitHub Jul 26, 2016
Showing with 20 additions and 4 deletions.
  1. +1 −3 generate/input/descriptor.json
  2. +1 −1 lib/tree.js
  3. +18 −0 test/tests/tree.js
View
4 generate/input/descriptor.json
@@ -2499,9 +2499,7 @@
"jsFunctionName": "_entryByIndex"
},
"git_tree_entry_byname": {
- "return": {
- "ownedByThis": true
- }
+ "jsFunctionName": "_entryByName"
},
"git_tree_entrycount": {
"jsFunctionName": "entryCount"
View
2 lib/tree.js
@@ -65,7 +65,7 @@ Tree.prototype.entryByIndex = function(i) {
* @return {TreeEntry}
*/
Tree.prototype.entryByName = function(name) {
- var entry = this.entryByName(name);
+ var entry = this._entryByName(name);
entry.parent = this;
return entry;
};
View
18 test/tests/tree.js
@@ -5,22 +5,40 @@ var promisify = require("promisify-node");
var fse = promisify(require("fs-extra"));
describe("Tree", function() {
+ var NodeGit = require("../../");
var RepoUtils = require("../utils/repository_setup");
var repoPath = local("../repos/tree");
+ var existingPath = local("../repos/workdir");
+ var oid = "5716e9757886eaf38d51c86b192258c960d9cfea";
beforeEach(function() {
var test = this;
return RepoUtils.createRepository(repoPath)
.then(function(repo) {
test.repository = repo;
+ }).then(function() {
+ return NodeGit.Repository.open(existingPath);
+ }).then(function(repository) {
+ test.existingRepo = repository;
+ return repository.getCommit(oid);
+ }).then(function(commit) {
+ test.commit = commit;
});
});
after(function() {
return fse.remove(repoPath);
});
+ it("gets an entry by name",
+ function(done) {
+ this.commit.getTree().then(function(tree) {
+ var entry = tree.entryByName("README.md");
+ assert(entry);
+ }).done(done);
+ });
+
it("walks its entries and returns the same entries on both progress and end",
function() {
var repo = this.repository;

0 comments on commit 1bfe672

Please sign in to comment.