Javascript 使用nodegit的签出分支不工作?
使用nodegit动态更新分支内容,因此在下面的代码中,我首先尝试检查分支,但这并没有发生。我正在从repo获得分支列表,知道如何实现该任务吗 main.jsJavascript 使用nodegit的签出分支不工作?,javascript,node.js,git,nodegit,Javascript,Node.js,Git,Nodegit,使用nodegit动态更新分支内容,因此在下面的代码中,我首先尝试检查分支,但这并没有发生。我正在从repo获得分支列表,知道如何实现该任务吗 main.js const nodegit = require('nodegit'); const fs = require ('fs') const getAllBranches = function(repository) { return repository.getReferenceNames(nodegit.Reference
const nodegit = require('nodegit');
const fs = require ('fs')
const getAllBranches = function(repository) {
return repository.getReferenceNames(nodegit.Reference.TYPE.ALL);
}
const checkoutBranch = function (repo, branches) {
for (const branch of branches) {
const master = "master";
if(branch.includes(master)) {
console.log("branch", branch);
repo. checkoutBranch(branch).then(function(ref){
return repo.checkoutRef(ref)
});
}
}
}
nodegit.Repository.open(dir)
.then(getAllBranches)
.then(function(branches ){
return checkoutBranch(dir,branches);
})
.then(function(branch){
console.log("checkout", branch);
})