[英]Using NodeGit CloneOptions to clone a branch
我試圖找出如何將克隆選項傳遞給nodegit克隆方法。
節點git文檔聲明克隆方法的第3個參數是克隆選項對象http://www.nodegit.org/nodegit/#Repo-clone
git.Repo.clone(URL, path, CloneOptions, callback);
但是,此對象不包含在nodegit的標准版本中。
我已將clone_options.cc文件的綁定添加到bindings.gyp文件中,我可以訪問克隆選項對象。 但是,我無法弄清楚如何使用有效的分支名稱實例化它。 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問題頁面上還有一個開放的線程
你可以嘗試這個......
var Git = require('nodegit');
var clone = Git.Clone.clone;
var branch = 'development';
var cloneOptions = new Git.CloneOptions();
cloneOptions.checkoutBranch = branch;
clone(url, directory, cloneOptions)
.then(function(repository){
console.log(repository);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.