mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
parent
11073cedd3
commit
ee582714b6
|
@ -10,6 +10,7 @@ import { denodeify } from './util';
|
|||
import * as path from 'path';
|
||||
import * as http from 'http';
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
const randomBytes = denodeify<Buffer>(crypto.randomBytes);
|
||||
|
@ -38,6 +39,7 @@ export class Askpass implements Disposable {
|
|||
|
||||
private server: http.Server;
|
||||
private ipcHandlePathPromise: Promise<string>;
|
||||
private ipcHandlePath: string | undefined;
|
||||
private enabled = true;
|
||||
|
||||
constructor() {
|
||||
|
@ -52,6 +54,7 @@ export class Askpass implements Disposable {
|
|||
const buffer = await randomBytes(20);
|
||||
const nonce = buffer.toString('hex');
|
||||
const ipcHandlePath = getIPCHandlePath(nonce);
|
||||
this.ipcHandlePath = ipcHandlePath;
|
||||
|
||||
try {
|
||||
this.server.listen(ipcHandlePath);
|
||||
|
@ -110,5 +113,9 @@ export class Askpass implements Disposable {
|
|||
|
||||
dispose(): void {
|
||||
this.server.close();
|
||||
|
||||
if (this.ipcHandlePath && process.platform !== 'win32') {
|
||||
fs.unlinkSync(this.ipcHandlePath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,6 +25,8 @@ async function init(context: ExtensionContext, outputChannel: OutputChannel, dis
|
|||
const pathHint = workspace.getConfiguration('git').get<string>('path');
|
||||
const info = await findGit(pathHint, path => outputChannel.appendLine(localize('looking', "Looking for git in: {0}", path)));
|
||||
const askpass = new Askpass();
|
||||
disposables.push(askpass);
|
||||
|
||||
const env = await askpass.getEnv();
|
||||
const git = new Git({ gitPath: info.path, version: info.version, env });
|
||||
const model = new Model(git, context.globalState, outputChannel);
|
||||
|
|
Loading…
Reference in a new issue