问题
I want to use the vscode git api in one my extension to do git clone and other tasks. Is it accessible from the vscode api ? The code is present here.. api
回答1:
Twitter to the rescue! I asked there and was pointed to the API definitions here: https://github.com/Microsoft/vscode/blob/master/extensions/git/src/api/git.d.ts
...and an example here: https://github.com/Microsoft/vscode-pull-request-github/blob/master/src/extension.ts#L53
// Import the git.d.ts file
import { API as GitAPI, GitExtension, APIState } from './typings/git';
const gitExtension = vscode.extensions.getExtension<GitExtension>('vscode.git').exports;
const api = gitExtension.getAPI(1);
const rootPath = vscode.workspace.rootPath;
const repository = api.repositories.filter(r => isDescendant(r.rootUri.fsPath, rootPath))[0];
来源:https://stackoverflow.com/questions/46511595/how-to-access-the-api-for-git-in-visual-studio-code