Permalink
Browse files

Add in remote listing support and test

  • Loading branch information...
1 parent 5480814 commit 15315cf41ad76400d9189c85a5827b77b8c392f1 @tbranyen tbranyen committed Jul 18, 2014
@@ -535,6 +535,26 @@
},
"remote": {
+ "dependencies": [
+ "../include/functions/copy.h",
+ "../include/remote.h",
+ "../include/strarray.h",
+ "../include/repository.h",
+ "../include/transport.h"
+ ],
+
+ "functions": {
+ "git_remote_list": {
+ "ignore": false,
+ "isConstructorMethod": true,
+ "args": [
+ { "shouldAlloc": true }
+ ],
+ "return": {
+ "copy": "git_strarray_copy"
+ }
+ }
+ }
},
"repository": {
@@ -648,6 +668,10 @@
"cType": null
},
+ "strarray": {
+ "cType": "git_strarray"
+ },
+
"submodule": {
},
@@ -23,7 +23,7 @@
],
"cflags": [
- "-Wall",
+ "-Wall"
],
"conditions": [
@@ -1,13 +1,16 @@
<% toName = to.name || 'result' -%>
<% if (to.cppClassName == "String") { -%>
-<% if (typeof to.size != 'undefined') { -%>
- to = NanNew<String>(<%- toName %>, <%- to.size %>);
-<% } else { -%>
- to = NanNew<String>(<%- toName %>);
-<% } -%>
-<% if (to.freeFunctionName) { -%>
- <%- to.freeFunctionName %>(<%- toName %>);
-<% } -%>
+ <% if (typeof to.size != 'undefined') { -%>
+to = NanNew<String>(<%- toName %>, <%- to.size %>);
+ <% } else if (to.cType === "char **") { -%>
+to = NanNew<String>(*<%- toName %>);
+ <% } else { -%>
+to = NanNew<String>(<%- toName %>);
+ <% } -%>
+
+ <% if (to.freeFunctionName) { -%>
+ <%- to.freeFunctionName %>(<%- toName %>);
+ <% } -%>
<% } else if (isV8Value(to.cppClassName)) { -%>
<% if (~['Uint32', 'Int32'].indexOf(to.cppClassName)) { -%>
<% var className = to.cppClassName.toLowerCase()+'_t' -%>
View
@@ -1993,8 +1993,8 @@
"js": "list"
},
"git_strarray *": {
- "js": "Strarray",
- "cpp": "Strarray"
+ "cpp": "GitStrarray",
+ "js": "Strarray"
},
"git_tag_list_match": {
"cpp": "ListMatch",
@@ -2062,7 +2062,7 @@
},
"git_strarray*": {
"js": "Strarray*",
- "cpp": "Strarray*"
+ "cpp": "GitStrarray*"
},
"git_revparse_single": {
"cpp": "RevparseSingle",
@@ -2213,8 +2213,8 @@
"js": "strarrayCopy"
},
"const git_strarray *": {
- "js": "Strarray",
- "cpp": "Strarray"
+ "cpp": "GitStrarray",
+ "js": "Strarray"
},
"git_submodule_foreach": {
"cpp": "Foreach",
@@ -9043,5 +9043,17 @@
"const git_diff_line *": {
"cpp": "GitDiffLine",
"js": "DiffLine"
+ },
+ "git_strarray": {
+ "cpp": "GitStrarray",
+ "js": "Strarray"
+ },
+ "git_strarray **": {
+ "cpp": "GitStrarray",
+ "js": "Strarray"
+ },
+ "const git_strarray **": {
+ "cpp": "GitStrarray",
+ "js": "Strarray"
}
}
View
@@ -0,0 +1,5 @@
+var NodeGit = require("../");
+
+var Remote = NodeGit.Remote;
+
+module.exports = Remote;
View
@@ -5,6 +5,7 @@ var Tree = require("./tree");
var Reference = require("./refs");
var Revwalk = require("./revwalk");
var Commit = require("./commit");
+var Remote = require("./remote");
var TreeBuilder = NodeGit.Treebuilder;
var Repository = NodeGit.Repository;
@@ -36,6 +37,22 @@ Repository.prototype.getBranch = function(name, callback) {
};
/**
+ * Lists out the remotes in the given repository.
+ *
+ * @param {Function} Optional callback
+ * @return {Object} Promise object.
+ */
+Repository.prototype.getRemotes = function(callback) {
+ return Remote.list(this).then(function(remotes) {
+ if (typeof callback === "function") {
+ callback(null, remotes);
+ }
+
+ return remotes;
+ }, callback);
+};
+
+/**
* Lookup the reference with the given name.
*
* @param {String} name
View
@@ -72,6 +72,7 @@
"test": "npm run lint && npm run mocha",
"publish": "node-pre-gyp package && node-pre-gyp publish",
"generate": "node generate/setup && node generate",
- "install": "npm run generate && node install"
+ "install": "npm run generate && node install",
+ "rebuild": "npm run generate && node-gyp configure build"
}
}
@@ -45,4 +45,11 @@ describe("Repository", function() {
assert.ok(index instanceof Index);
});
});
+
+ it("can list remotes", function() {
+ return this.repository.getRemotes().then(function(remotes) {
+ assert.equal(remotes.count(), 1);
+ assert.equal(remotes.strings(), "origin");
+ });
+ });
});

0 comments on commit 15315cf

Please sign in to comment.