Tag: libgit2

如何使用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 […]

使用NodeGit CloneOptions克隆分支

我正在尝试解决如何将克隆选项传递给nodegit克隆方法。 节点git文档指出,clone方法的第三个参数是clone选项对象http://www.nodegit.org/nodegit/#Repo-clone git.Repo.clone(URL, path, CloneOptions, callback); 但是这个对象不包含在nodegit的标准构build中。 我已经将clone_options.cc文件的绑定添加到了bindings.gyp文件中,并且可以访问clone选项对象。 不过,我不能解决如何使用有效的分支名称来实例化它。 libgit2 api显示该选项是checkout_branch http://libgit2.github.com/libgit2/#HEAD/type/git_clone_options 任何人有任何见解如何做到这一点? 或者在一个支持在节点中克隆git分支的替代库? var CloneOptions = nodegit.CloneOptions; var options = new CloneOptions({checkout_branch: branchName}); git.Repo.clone(url, temp, options, function (err, repo) {…}); 结果是 Error: git_clone_options is required. nodegit的github问题页面上也有一个开放的线程 https://github.com/nodegit/nodegit/issues/127