javascript - Nodegit 如何获取新的分支列表?
问题描述
open(o.localPath).then(function (repo) {
repository = repo;
return repo.fetchAll(credentials);
}).then(function () {
return repository.getReferenceNames(Git.Reference.TYPE.LISTALL);
}).then(function (arrayString) {
console.log(arrayString);
}).catch(err => {
reject(err);
})
我获取了所有分支一次(总共 5 个分支),我删除了一个分支,本地和远程,这仍然返回 5 个分支,但它应该返回 4 个分支,我怎样才能获得新的分支列表?
解决方案
repository.getReferenceNames(Git.Reference.TYPE.LISTALL);
可以是同义词
git show-ref
命令。
这是使用.git/refs
文件夹中的引用。
您希望git fetch --all --prune
在删除分支时运行 a 以删除远程中删除的远程跟踪引用。
取决于您的 nodegit 版本(适用于[v0.5.0]及更高版本)
//...
const fetchOptions = { callbacks: credentials, pruneAfter: true }
return repo.fetchAll(fetchOptions)
//...
//...
return repo.fetchAll(remoteCallbacks, true)
//...
推荐阅读
- c# - XML 序列化错误 - 类型为“ItemsChoiceType[]”的选择标识符“ItemsElementName”的值无效或缺失
- json - 在Angular 5中进行创建后操作时出了什么问题
- ios - 为什么fastlane上传到TestFlight在代理后面失败?
- c# - xamarin stacklayout child 删除自己
- amazon-web-services - 在 DynamoDB 中同时(同一秒)发生多个读取或写入请求时会发生什么?
- azure - 使用 Terraform 的 Azure 容器注册表权限
- ios - Swift bool 数据未传递到 tableview 单元格
- django - Django:在 ModelForm 上注入表单验证,而不是 Model
- python - 使用 Pandas 将 CSV 文件连接在一起
- sql - AWS Athena 中的特殊字符显示为问号