mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
@@ -10,6 +10,7 @@ import { denodeify } from './util';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
|
import * as fs from 'fs';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
||||||
const randomBytes = denodeify<Buffer>(crypto.randomBytes);
|
const randomBytes = denodeify<Buffer>(crypto.randomBytes);
|
||||||
@@ -38,6 +39,7 @@ export class Askpass implements Disposable {
|
|||||||
|
|
||||||
private server: http.Server;
|
private server: http.Server;
|
||||||
private ipcHandlePathPromise: Promise<string>;
|
private ipcHandlePathPromise: Promise<string>;
|
||||||
|
private ipcHandlePath: string | undefined;
|
||||||
private enabled = true;
|
private enabled = true;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -52,6 +54,7 @@ export class Askpass implements Disposable {
|
|||||||
const buffer = await randomBytes(20);
|
const buffer = await randomBytes(20);
|
||||||
const nonce = buffer.toString('hex');
|
const nonce = buffer.toString('hex');
|
||||||
const ipcHandlePath = getIPCHandlePath(nonce);
|
const ipcHandlePath = getIPCHandlePath(nonce);
|
||||||
|
this.ipcHandlePath = ipcHandlePath;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.server.listen(ipcHandlePath);
|
this.server.listen(ipcHandlePath);
|
||||||
@@ -110,5 +113,9 @@ export class Askpass implements Disposable {
|
|||||||
|
|
||||||
dispose(): void {
|
dispose(): void {
|
||||||
this.server.close();
|
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 pathHint = workspace.getConfiguration('git').get<string>('path');
|
||||||
const info = await findGit(pathHint, path => outputChannel.appendLine(localize('looking', "Looking for git in: {0}", path)));
|
const info = await findGit(pathHint, path => outputChannel.appendLine(localize('looking', "Looking for git in: {0}", path)));
|
||||||
const askpass = new Askpass();
|
const askpass = new Askpass();
|
||||||
|
disposables.push(askpass);
|
||||||
|
|
||||||
const env = await askpass.getEnv();
|
const env = await askpass.getEnv();
|
||||||
const git = new Git({ gitPath: info.path, version: info.version, env });
|
const git = new Git({ gitPath: info.path, version: info.version, env });
|
||||||
const model = new Model(git, context.globalState, outputChannel);
|
const model = new Model(git, context.globalState, outputChannel);
|
||||||
|
|||||||
Reference in New Issue
Block a user