Skip to content

Commit 9622ada

Browse files
committed
find git in LocalAppData and PATH, win32
fixes microsoft#40229
1 parent 4e5de4b commit 9622ada

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

extensions/git/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,13 +968,15 @@
968968
"file-type": "^7.2.0",
969969
"iconv-lite": "0.4.19",
970970
"vscode-extension-telemetry": "0.0.8",
971-
"vscode-nls": "2.0.2"
971+
"vscode-nls": "2.0.2",
972+
"which": "^1.3.0"
972973
},
973974
"devDependencies": {
974975
"@types/byline": "4.2.31",
975976
"@types/file-type": "^5.2.1",
976977
"@types/mocha": "2.2.43",
977978
"@types/node": "7.0.43",
979+
"@types/which": "^1.0.28",
978980
"mocha": "^3.2.0"
979981
}
980-
}
982+
}

extensions/git/src/git.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as fs from 'fs';
99
import * as path from 'path';
1010
import * as os from 'os';
1111
import * as cp from 'child_process';
12+
import * as which from 'which';
1213
import { EventEmitter } from 'events';
1314
import iconv = require('iconv-lite');
1415
import * as filetype from 'file-type';
@@ -124,10 +125,17 @@ function findSystemGitWin32(base: string, onLookup: (path: string) => void): Pro
124125
return findSpecificGit(path.join(base, 'Git', 'cmd', 'git.exe'), onLookup);
125126
}
126127

128+
function findGitWin32InPath(onLookup: (path: string) => void): Promise<IGit> {
129+
const whichPromise = new Promise<string>((c, e) => which('git.exe', (err, path) => err ? e(err) : c(path)));
130+
return whichPromise.then(path => findSpecificGit(path, onLookup));
131+
}
132+
127133
function findGitWin32(onLookup: (path: string) => void): Promise<IGit> {
128134
return findSystemGitWin32(process.env['ProgramW6432'] as string, onLookup)
129135
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles(x86)'] as string, onLookup))
130-
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles'] as string, onLookup));
136+
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles'] as string, onLookup))
137+
.then(void 0, () => findSystemGitWin32(path.join(process.env['LocalAppData'] as string, 'Programs'), onLookup))
138+
.then(void 0, () => findGitWin32InPath(onLookup));
131139
}
132140

133141
export function findGit(hint: string | undefined, onLookup: (path: string) => void): Promise<IGit> {

extensions/git/yarn.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
version "7.0.43"
2727
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c"
2828

29+
"@types/which@^1.0.28":
30+
version "1.0.28"
31+
resolved "https://registry.yarnpkg.com/@types/which/-/which-1.0.28.tgz#016e387629b8817bed653fe32eab5d11279c8df6"
32+
2933
applicationinsights@0.18.0:
3034
version "0.18.0"
3135
resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-0.18.0.tgz#162ebb48a383408bc4de44db32b417307f45bbc1"
@@ -123,6 +127,10 @@ inherits@2:
123127
version "2.0.3"
124128
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
125129

130+
isexe@^2.0.0:
131+
version "2.0.0"
132+
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
133+
126134
json3@3.3.2:
127135
version "3.3.2"
128136
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1"
@@ -238,6 +246,12 @@ vscode-nls@2.0.2:
238246
version "2.0.2"
239247
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-2.0.2.tgz#808522380844b8ad153499af5c3b03921aea02da"
240248

249+
which@^1.3.0:
250+
version "1.3.0"
251+
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
252+
dependencies:
253+
isexe "^2.0.0"
254+
241255
winreg@1.2.3:
242256
version "1.2.3"
243257
resolved "https://registry.yarnpkg.com/winreg/-/winreg-1.2.3.tgz#93ad116b2696da87d58f7265a8fcea5254a965d5"

0 commit comments

Comments
 (0)