4
我试图在利用图书馆nodegit(版本0.2.4)和ssh的node.js我们TeamForge的服务器克隆的Git仓库克隆用nodegit的Git仓库。 我们的服务器请求来自用户的身份验证,并且当我试图仅使用克隆方法而未传递选项时,出现错误:“回调无法初始化SSH凭据”。如何使用ssh
我在文件private.key和public.key私钥和公钥。它们位于我在web风暴中设置为工作目录的目录中,因此位置不应该成为问题。
没有找到例子,如何做到这一点(也许我错过了),但下面的代码是我得到的最接近:
'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://[email protected]/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)
你有暗示什么可能是错的,或者一般如何去做?
我跑这条线的线仅交换了SSH URL和目录名,并获得'错误:需要身份验证,但没有回调set' – TheEnvironmentalist 2017-09-14 16:05:21
目前已经在nodegit API的变化。在选项中,只需用'callbacks'替换'remoteCallbacks',如下所示:http://www.nodegit.org/api/fetch_options/ – bumblebee 2017-11-09 15:07:59