feat: resolve Git binary path from VS Code settings and enhance Git detection

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Elio Struyf
2026-04-23 13:22:16 +02:00
parent a7e487f036
commit c723a02dc7
2 changed files with 24 additions and 2 deletions
+1
View File
@@ -6,6 +6,7 @@
- [#1023](https://github.com/estruyf/vscode-front-matter/issues/1023): Fix validation errors for image, file, and keywords fields
- [#1024](https://github.com/estruyf/vscode-front-matter/issues/1024): Re-add the `frontMatter.copilot.enabled` setting to allow users to disable the GitHub Copilot integration
- Fix Git detection when Git is configured via VS Code `git.path` and not installed globally on the system
## [10.10.0] - 2026-04-03 - [Release notes](https://beta.frontmatter.codes/updates/v10.10.0)
+23 -2
View File
@@ -26,7 +26,7 @@ import {
import { GeneralCommands } from './../../constants/GeneralCommands';
import simpleGit, { SimpleGit } from 'simple-git';
import { Folders } from '../../commands/Folders';
import { Event, commands, extensions } from 'vscode';
import { Event, commands, extensions, workspace } from 'vscode';
import { GitAPIState, GitRepository, PostMessageData } from '../../models';
import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../../localization';
@@ -343,7 +343,7 @@ export class GitListener {
const options = {
baseDir: submoduleFolder || wsFolder?.fsPath || '',
binary: 'git',
binary: GitListener.getGitBinary(),
maxConcurrentProcesses: 6
};
@@ -356,6 +356,27 @@ export class GitListener {
}
}
/**
* Resolves the Git binary path from VS Code settings.
* Falls back to the default `git` command when no custom path is configured.
*/
private static getGitBinary(): string {
const gitPath = workspace.getConfiguration('git').get<string | string[]>('path');
if (Array.isArray(gitPath)) {
const firstValidPath = gitPath.find((path) => typeof path === 'string' && path.trim());
if (firstValidPath) {
return firstValidPath;
}
}
if (typeof gitPath === 'string' && gitPath.trim()) {
return gitPath;
}
return 'git';
}
/**
* Initializes the VS Code Git provider and sets up event listeners for repository changes.
* @returns {Promise<void>} A promise that resolves when the Git provider is initialized.