Browse Source

Adds support for git.path array

main
Eric Amodio 4 years ago
parent
commit
ae47fbd175
3 changed files with 16 additions and 6 deletions
  1. +1
    -1
      src/git/git.ts
  2. +1
    -1
      src/git/gitService.ts
  3. +14
    -4
      src/git/locator.ts

+ 1
- 1
src/git/git.ts View File

@ -217,7 +217,7 @@ export namespace Git {
return gitInfo.version; return gitInfo.version;
} }
export async function setOrFindGitPath(gitPath?: string): Promise<void> {
export async function setOrFindGitPath(gitPath?: string | string[]): Promise<void> {
const start = process.hrtime(); const start = process.hrtime();
gitInfo = await findGitPath(gitPath); gitInfo = await findGitPath(gitPath);

+ 1
- 1
src/git/gitService.ts View File

@ -154,7 +154,7 @@ export class GitService implements Disposable {
gitPath = gitApi.git.path; gitPath = gitApi.git.path;
} }
await Git.setOrFindGitPath(gitPath ?? configuration.getAny<string>('git.path'));
await Git.setOrFindGitPath(gitPath ?? configuration.getAny<string | string[]>('git.path'));
} }
get readonly() { get readonly() {

+ 14
- 4
src/git/locator.ts View File

@ -63,10 +63,20 @@ function findGitWin32(): Promise {
.then(null, () => findSpecificGit('git')); .then(null, () => findSpecificGit('git'));
} }
export async function findGitPath(path?: string): Promise<GitLocation> {
export async function findGitPath(paths?: string | string[]): Promise<GitLocation> {
try { try {
return await findSpecificGit(path ?? 'git');
} catch (ex) {
if (paths == null || typeof paths === 'string') {
return await findSpecificGit(paths ?? 'git');
}
for (const path of paths) {
try {
return await findSpecificGit(path);
} catch {}
}
throw new Error('Unable to find git');
} catch {
try { try {
switch (process.platform) { switch (process.platform) {
case 'darwin': case 'darwin':
@ -76,7 +86,7 @@ export async function findGitPath(path?: string): Promise {
default: default:
return Promise.reject('Unable to find git'); return Promise.reject('Unable to find git');
} }
} catch (ex) {
} catch {
return Promise.reject(new Error('Unable to find git')); return Promise.reject(new Error('Unable to find git'));
} }
} }

Loading…
Cancel
Save