Closed MarcMenghin closed 4 years ago
Hello Marc!
Thank you for the issue.
Right now we use a crude implementation of the vscode.git
extension api to get the git path. If we can't get it from that built in extension we default to attempting git
in the path.
Sometimes it can take a while for vscode.git
to get activated. Perhaps this is what you are experiencing? Does it start working after a short while (10-15 seconds)?
Git extension works as expected where I can push/pull/commit. If I open a file vs code reports the git blame error.
So, it does not start to work at any later point in time. It does work fine as soon as I put git on the path.
Furthermore, I am on the newest version of VS Code and its extensions. (just today updated to 1.39.0 with same problem)
Also, other Git related extensions (e.g. Git Graph, Git History) work fine as well.
Did check the code for Git Graph (which searches a lot for git exe, not ideal) and Git History which uses this:
this.gitExtension = extensions.getExtension('vscode.git');
this.gitApi = this.gitExtension!.exports.getAPI(1);
this.gitExecutablePath = this.gitApi.git.path;
which looks closer to the example you mentioned. So, maybe that missing .getAPI(1)
is to blame?
Thank you for the research and quick responses!
Last time I tried to implement the getAPI
function it had some issues. I can't remember exactly what but in the experiments I did yesterday it looks like it is working now. I will change getGitCommand
to the following in the next version:
export async function getGitCommand(): Promise<string> {
const vscodeGit = extensions.getExtension<GitExtension>(
"vscode.git",
);
if (vscodeGit && vscodeGit.exports.enabled) {
const api = vscodeGit.exports.getAPI(1);
if (api.state === "initialized") {
return api.git.path;
} else {
return new Promise((resolve): void => {
api.onDidChangeState((newState): void => {
if (newState === "initialized") {
resolve(api.git.path);
}
});
});
}
}
return GIT_COMMAND_IN_PATH;
}
A fix for this was uploaded to the marketplace just now. It should be available in a few hours to a day.
Git command will not be found/usable if not on path (?). VS Code already has a setting "git.path" which is set but not used by git blame it seems.
So Git works as expected in VS Code, Git Blame reports an error that git can not be executed.
Note: File is not outside of Workspace.