在开发Visual Studio Code(vscode)扩展时,我问自己如何使用 native 方法正确读取git refs,例如当前分支。
我当前的解决方案更像是一种解决方法:
git rev-parse', '--abbrev-ref', 'HEAD'
完整的方法实现here(分支扩展gitHistoryVSCode)
还有其他想法,例如如何访问扩展/git方法或模型属性?
最佳答案
native git扩展现在提供了几种方法/属性来获取当前分支以及所有分支
在此处查看git扩展api引用:
获取分支
https://github.com/microsoft/vscode/blob/master/extensions/git/src/api/api1.ts#L160
获取分支
https://github.com/microsoft/vscode/blob/master/extensions/git/src/api/api1.ts#L164
关于git - 使用vscode扩展 native 读取当前git分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45171300/