如何使用ssh克隆git仓库与nodegit

我试图使用库nodegit(版本0.2.4)和ssh从node.js中的teamforge服务器中克隆git仓库。 我们的服务器请求来自用户的身份validation,当我试图只使用克隆方法而不传递选项时,我得到错误:“callback无法初始化SSH凭据”。

我有private.key和public.key文件中的私钥和公钥。 他们在我已经设置为web风暴工作目录的目录中,所以位置不应该是一个问题。

没有find例子如何做到这一点(也许我错过了),但下面的代码是最接近我得到:

'use strict'; var nodegit = require("nodegit"), Clone = nodegit.Clone, cred = nodegit.Cred; var options = { remoteCallbacks: { credentials: function () { return cred.sshKeyNew('user', 'public.key', 'private.key', ''); } } }; Clone.clone("ssh://user@teamforgeserver.net/reponame", "localTmp", options) .then(function(repo) { var r = repo; }, function(err){ var e = err; } ); 

我得到这个错误:

 TypeError: Object #<Object> has no method 'isFulfilled' at value (c:\...\proj\node_modules\nodegit\node_modules\nodegit-promise\lib\core.js:36:15) 

你有提示什么可能是错的,或者一般如何做?

这是创build一个新的SSH密钥的错误。 我在这里创build了一个问题来跟踪它。

同时,如果您运行SSH代理,则可以从中获取凭据。

 'use strict'; var nodegit = require("nodegit"), Clone = nodegit.Clone, cred = nodegit.Cred; var options = { fetchOpts: { remoteCallbacks: { credentials: function (url, userName) { // this is changed from sshKeyNew to sshKeyFromAgent return cred.sshKeyFromAgent(userName); } } } }; Clone.clone("ssh://user@teamforgeserver.net/reponame", "localTmp", options) .then(function(repo) { var r = repo; }, function(err){ var e = err; } ); 

这在v0.2.4中适用于我。 如果您需要更多实时支持,请随时在我们的gitter频道与我们聊天。

更新:我只是在合并请求#334上添加了一个修复程序。 testing通过后,我会把这个在主,然后问题中的代码应该正常工作。