2015-04-06 100 views
1

我试图使用Nodegit插件clone一些git回到一个名为'tmp'的目录中,这样我就可以对实际文件夹进行操作(将其上传到服务器)。这里是我的代码:Nodegit克隆不起作用?

var git = require('nodegit'); 

var repos = [some https repo urls] 

var options = { 
    remoteCallbacks: { 
     certificateCheck: function() { 
      return 1; 
     } 
    } 
}; 

for(i = 0; i<repos.length; i++){ 
    git.Clone(repos[i], './tmp', options).catch(function(err) { console.error(err); }); 
} 

它所做的就是为分裂创建一个名为“TMP”的空目录,第二和删除。我得到的错误是./tmp' exists and is not an empty directory(但它不存在?)和authentication required but no callback set。任何人知道如何解决这些问题?

+0

我还没有使用该项目,但看着文档NodeGit似乎支持承诺,所以添加一个类似'git.Clone(repos [i],'./tmp).catch(function (err){console.log(err);});'看看发生了什么问题。 – orbitbot

+0

谢谢@orbitbot。我添加了错误情况并更新了错误信息。 – Bramt

回答

1

由于@ johnhaley81在gitter中提到,您应该签出测试代码here。覆盖certificateCheck应解决The SSL certificate is invalid错误。

./tmp错误是有意义的,因为您试图将多个存储库克隆到同一个目录中。