While I am developing an extension for Visual Studio Code (vscode) I have asked myself how to proper read git refs like the current branch using native methods.
My current solutions feels more like a workaround:
git rev-parse', '--abbrev-ref', 'HEAD'
Complete method implemented here (forked extension gitHistoryVSCode)
Any other ideas, for example how to access the extension/git methods or model properties?
The native git extension now provides several methods / properties to fetch the current branch as well as all branches
Check out the git extension api reference here:
get branches https://github.com/microsoft/vscode/blob/1ab31376742390f215736283dfb763e3a13bced9/extensions/git/src/api/api1.ts#L164