diff --git a/extensions/git/package.json b/extensions/git/package.json index e59670ac0c1..685e59ea5a7 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -968,13 +968,15 @@ "file-type": "^7.2.0", "iconv-lite": "0.4.19", "vscode-extension-telemetry": "0.0.8", - "vscode-nls": "2.0.2" + "vscode-nls": "2.0.2", + "which": "^1.3.0" }, "devDependencies": { "@types/byline": "4.2.31", "@types/file-type": "^5.2.1", "@types/mocha": "2.2.43", "@types/node": "7.0.43", + "@types/which": "^1.0.28", "mocha": "^3.2.0" } -} \ No newline at end of file +} diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index c39b96c6045..3ec01de6f17 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -9,6 +9,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as os from 'os'; import * as cp from 'child_process'; +import * as which from 'which'; import { EventEmitter } from 'events'; import iconv = require('iconv-lite'); import * as filetype from 'file-type'; @@ -124,10 +125,17 @@ function findSystemGitWin32(base: string, onLookup: (path: string) => void): Pro return findSpecificGit(path.join(base, 'Git', 'cmd', 'git.exe'), onLookup); } +function findGitWin32InPath(onLookup: (path: string) => void): Promise { + const whichPromise = new Promise((c, e) => which('git.exe', (err, path) => err ? e(err) : c(path))); + return whichPromise.then(path => findSpecificGit(path, onLookup)); +} + function findGitWin32(onLookup: (path: string) => void): Promise { return findSystemGitWin32(process.env['ProgramW6432'] as string, onLookup) .then(void 0, () => findSystemGitWin32(process.env['ProgramFiles(x86)'] as string, onLookup)) - .then(void 0, () => findSystemGitWin32(process.env['ProgramFiles'] as string, onLookup)); + .then(void 0, () => findSystemGitWin32(process.env['ProgramFiles'] as string, onLookup)) + .then(void 0, () => findSystemGitWin32(path.join(process.env['LocalAppData'] as string, 'Programs'), onLookup)) + .then(void 0, () => findGitWin32InPath(onLookup)); } export function findGit(hint: string | undefined, onLookup: (path: string) => void): Promise { diff --git a/extensions/git/yarn.lock b/extensions/git/yarn.lock index 9f5376164a6..a9d4c679d30 100644 --- a/extensions/git/yarn.lock +++ b/extensions/git/yarn.lock @@ -26,6 +26,10 @@ version "7.0.43" resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c" +"@types/which@^1.0.28": + version "1.0.28" + resolved "https://registry.yarnpkg.com/@types/which/-/which-1.0.28.tgz#016e387629b8817bed653fe32eab5d11279c8df6" + applicationinsights@0.18.0: version "0.18.0" resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-0.18.0.tgz#162ebb48a383408bc4de44db32b417307f45bbc1" @@ -123,6 +127,10 @@ inherits@2: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + json3@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" @@ -238,6 +246,12 @@ vscode-nls@2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-2.0.2.tgz#808522380844b8ad153499af5c3b03921aea02da" +which@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" + dependencies: + isexe "^2.0.0" + winreg@1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/winreg/-/winreg-1.2.3.tgz#93ad116b2696da87d58f7265a8fcea5254a965d5"