Skip to content
Merged
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
10 changes: 8 additions & 2 deletions generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@
"ignore": true
},
"git_packbuilder_new": {
"ignore": true
"isAsync": false
},
"git_packbuilder_set_callbacks": {
"ignore": true
Expand Down Expand Up @@ -1182,6 +1182,9 @@
"functions": {
"git_pathspec_match_list_free": {
"ignore": true
},
"git_pathspec_new": {
"isAsync": false
}
}
},
Expand Down Expand Up @@ -1306,6 +1309,9 @@
"remote": {
"cType": "git_remote",
"functions": {
"git_remote_create": {
"isAsync": false
},
"git_remote_connect": {
"isAsync": true,
"return": {
Expand Down Expand Up @@ -1596,7 +1602,7 @@
"status_list": {
"functions": {
"git_status_list_new": {
"isAsync": true,
"isAsync": false,
"args": {
"opts": {
"isOptional": true
Expand Down
10 changes: 4 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ Index.prototype.addAll = function(pathspec, flags, matchedCallback) {
paths.push(path);
};
var idx = this;
return Pathspec.create(pathspec || "*")
.then(function(ps) {
pathspec = ps;
return Status.foreach(repo, statusCB);
})
var ps = Pathspec.create(pathspec || "*");

return Status.foreach(repo, statusCB)
.then(function() {
return paths;
})
.then(function(paths) {
paths = paths.filter(function(path) {
return !!(pathspec.matchesPath(0, path));
return !!(ps.matchesPath(0, path));
});
return addAll.call(idx, paths, flags, matchedCallback, null);
});
Expand Down
14 changes: 7 additions & 7 deletions lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,14 +798,14 @@ Repository.prototype.getStatusExt = function(opts) {
};
}

return StatusList.create(this, opts).then(function(list) {
for (var i = 0; i < list.entrycount(); i++) {
var entry = Status.byIndex(list, i);
statuses.push(new StatusFile({entry: entry}));
}
var list = StatusList.create(this, opts);

return statuses;
});
for (var i = 0; i < list.entrycount(); i++) {
var entry = Status.byIndex(list, i);
statuses.push(new StatusFile({entry: entry}));
}

return statuses;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"cov": "npm run cppcov && npm run filtercov && npm run mergecov",
"mocha": "mocha test/runner test/tests",
"mochaDebug": "mocha --debug-brk test/runner test/tests",
"test": "npm run lint && iojs --expose-gc test || node --expose-gc test",
"test": "npm run lint && (iojs --expose-gc test || node --expose-gc test)",
"generateJson": "node generate/scripts/generateJson",
"generateNativeCode": "node generate/scripts/generateNativeCode",
"generateMissingTests": "node generate/scripts/generateMissingTests",
Expand Down
2 changes: 1 addition & 1 deletion test/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var writeFile = promisify(function(filename, data, callback) {
describe("Index", function() {
var NodeGit = require("../../");
var Repository = NodeGit.Repository;

var reposPath = local("../repos/workdir");

beforeEach(function() {
Expand Down
25 changes: 25 additions & 0 deletions test/tests/packbuilder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var assert = require("assert");
var path = require("path");
var local = path.join.bind(path, __dirname);

describe("Packbuilder", function() {
var NodeGit = require("../../");
var Repository = NodeGit.Repository;
var Packbuilder = NodeGit.Packbuilder;

var reposPath = local("../repos/workdir");

beforeEach(function() {
var test = this;

return Repository.open(reposPath).then(function(repository) {
test.repository = repository;
});
});

it("can be initialized", function() {
var packBuilder = Packbuilder.create(this.repository);

assert(packBuilder instanceof Packbuilder);
});
});
52 changes: 23 additions & 29 deletions test/tests/pathspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,40 @@ describe("Pathspec", function() {
var Pathspec = NodeGit.Pathspec;

it("can accept just about anything against a * pathspec", function() {
return Pathspec.create("*")
.then(function(pathspec) {
assert.equal(pathspec.matchesPath(0, "burritoooo"), 1);
assert.equal(pathspec.matchesPath(0, "bob/ted/yoghurt.mp3"), 1);
});
var pathspec = Pathspec.create("*");

assert.equal(pathspec.matchesPath(0, "burritoooo"), 1);
assert.equal(pathspec.matchesPath(0, "bob/ted/yoghurt.mp3"), 1);
});

it("can take a * in an array", function() {
return Pathspec.create(["*"])
.then(function(pathspec) {
assert.equal(pathspec.matchesPath(0, "burritoooo"), 1);
assert.equal(pathspec.matchesPath(0, "bob/ted/yoghurt.mp3"), 1);
});
var pathspec = Pathspec.create("*");

assert.equal(pathspec.matchesPath(0, "burritoooo"), 1);
assert.equal(pathspec.matchesPath(0, "bob/ted/yoghurt.mp3"), 1);
});

it("can take a single file", function() {
return Pathspec.create(["myDir/burritoSupreme.mp4"])
.then(function(pathspec) {
assert.equal(pathspec.matchesPath(0, "myDir/burritoSupreme.mp4"), 1);
assert.equal(pathspec.matchesPath(0, "bob/ted/yoghurt.mp3"), 0);
});
var pathspec = Pathspec.create(["myDir/burritoSupreme.mp4"]);

assert.equal(pathspec.matchesPath(0, "myDir/burritoSupreme.mp4"), 1);
assert.equal(pathspec.matchesPath(0, "bob/ted/yoghurt.mp3"), 0);
});

it("can take files in an array", function() {
return Pathspec.create(["gwendoline.txt", "sausolito.ogg"])
.then(function(pathspec) {
assert.equal(pathspec.matchesPath(0, "gwendoline.txt"), 1);
assert.equal(pathspec.matchesPath(0, "sausolito.ogg"), 1);
assert.equal(pathspec.matchesPath(0, "sausolito.txt"), 0);
});
var pathspec = Pathspec.create(["gwendoline.txt", "sausolito.ogg"]);

assert.equal(pathspec.matchesPath(0, "gwendoline.txt"), 1);
assert.equal(pathspec.matchesPath(0, "sausolito.ogg"), 1);
assert.equal(pathspec.matchesPath(0, "sausolito.txt"), 0);
});

it("can handle dirs", function() {
return Pathspec.create(["myDir/", "bob.js"])
.then(function(pathspec) {
assert.equal(pathspec.matchesPath(0, "bob.js"), 1);
assert.equal(pathspec.matchesPath(0, "myDir/bob2.js"), 1);
assert.equal(pathspec.matchesPath(0, "bob2.js"), 0);
assert.equal(pathspec.matchesPath(0, "herDir/bob.js"), 0);
});
});
var pathspec = Pathspec.create(["myDir/", "bob.js"]);

assert.equal(pathspec.matchesPath(0, "bob.js"), 1);
assert.equal(pathspec.matchesPath(0, "myDir/bob2.js"), 1);
assert.equal(pathspec.matchesPath(0, "bob2.js"), 0);
assert.equal(pathspec.matchesPath(0, "herDir/bob.js"), 0);
});
});
77 changes: 33 additions & 44 deletions test/tests/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,10 @@ describe("Remote", function() {

it("can set a remote", function() {
var repository = this.repository;
var newRemote;
var remote = Remote.create(repository, "origin1", url);

return Remote.create(repository, "origin1", url)
.then(function(remote) {
newRemote = remote;
return remote.setPushurl("https://google.com/");
})
.then(function() {
assert(newRemote.pushurl(), "https://google.com/");
});
remote.setPushurl("https://google.com/");
assert(remote.pushurl(), "https://google.com/");
});

it("can read the remote name", function() {
Expand All @@ -71,24 +65,20 @@ describe("Remote", function() {

it("can create and load a new remote", function() {
var repository = this.repository;
var remote = Remote.create(repository, "origin2", url);

return Remote.create(repository, "origin2", url)
.then(function() {
return Remote.lookup(repository, "origin2");
})
.then(function(remote) {
assert(remote.url(), url);
});
return Remote.lookup(repository, "origin2").then(function() {
assert(remote.url(), url);
});
});

it("can delete a remote", function() {
var repository = this.repository;
Remote.create(repository, "origin3", url);

return Remote.create(repository, "origin3", url)
.then(function(remote) {
Remote.delete(repository, "origin3");
return Remote.lookup(repository, "origin3");
})
Remote.delete(repository, "origin3");

return Remote.lookup(repository, "origin3")
.then(Promise.reject, Promise.resolve);
});

Expand Down Expand Up @@ -119,31 +109,30 @@ describe("Remote", function() {
var repo = this.repository;
var wasCalled = false;

return Remote.create(repo, "test2", url2)
.then(function() {
return repo.getRemote("test2");
})
.then(function(remote) {
remote.setCallbacks({
credentials: function(url, userName) {
return NodeGit.Cred.sshKeyFromAgent(userName);
},
certificateCheck: function() {
return 1;
},

transferProgress: function() {
wasCalled = true;
}
});
Remote.create(repo, "test2", url2);

return remote.fetch(null, repo.defaultSignature(), null);
})
.then(function() {
assert.ok(wasCalled);
return repo.getRemote("test2")
.then(function(remote) {
remote.setCallbacks({
credentials: function(url, userName) {
return NodeGit.Cred.sshKeyFromAgent(userName);
},
certificateCheck: function() {
return 1;
},

Remote.delete(repo, "test2");
});
transferProgress: function() {
wasCalled = true;
}
});

return remote.fetch(null, repo.defaultSignature(), null);
})
.then(function() {
assert.ok(wasCalled);

Remote.delete(repo, "test2");
});
});

it("can fetch from a remote", function() {
Expand Down
12 changes: 6 additions & 6 deletions test/tests/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ describe("Repository", function() {

return fse.writeFile(filePath, fileContent)
.then(function() {
return repo.getStatusExt().then(function(statuses) {
assert.equal(statuses.length, 1);
assert.equal(statuses[0].path(), fileName);
assert.equal(statuses[0].indexToWorkdir().newFile().path(), fileName);
assert.ok(statuses[0].isNew());
});
var statuses = repo.getStatusExt();

assert.equal(statuses.length, 1);
assert.equal(statuses[0].path(), fileName);
assert.equal(statuses[0].indexToWorkdir().newFile().path(), fileName);
assert.ok(statuses[0].isNew());
})
.then(function() {
return fse.remove(filePath);
Expand Down