Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'
This commit is contained in:
57
lib/vscode/extensions/git-ui/src/main.ts
Normal file
57
lib/vscode/extensions/git-ui/src/main.ts
Normal file
@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtensionContext, commands } from 'vscode';
|
||||
|
||||
import * as cp from 'child_process';
|
||||
|
||||
export async function deactivate(): Promise<any> {
|
||||
}
|
||||
|
||||
export async function activate(context: ExtensionContext): Promise<void> {
|
||||
context.subscriptions.push(commands.registerCommand('git.credential', async (data: any) => {
|
||||
try {
|
||||
const { stdout, stderr } = await exec(`git credential ${data.command}`, {
|
||||
stdin: data.stdin,
|
||||
env: Object.assign(process.env, { GIT_TERMINAL_PROMPT: '0' })
|
||||
});
|
||||
return { stdout, stderr, code: 0 };
|
||||
} catch ({ stdout, stderr, error }) {
|
||||
const code = error.code || 0;
|
||||
if (stderr.indexOf('terminal prompts disabled') !== -1) {
|
||||
stderr = '';
|
||||
}
|
||||
return { stdout, stderr, code };
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
export interface ExecResult {
|
||||
error: Error | null;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
}
|
||||
|
||||
|
||||
export function exec(command: string, options: cp.ExecOptions & { stdin?: string } = {}) {
|
||||
return new Promise<ExecResult>((resolve, reject) => {
|
||||
const child = cp.exec(command, options, (error, stdout, stderr) => {
|
||||
(error ? reject : resolve)({ error, stdout, stderr });
|
||||
});
|
||||
if (options.stdin) {
|
||||
child.stdin!.write(options.stdin, (err: any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
child.stdin!.end((err: any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
8
lib/vscode/extensions/git-ui/src/typings/refs.d.ts
vendored
Normal file
8
lib/vscode/extensions/git-ui/src/typings/refs.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path='../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>
|
||||
/// <reference types='@types/node'/>
|
Reference in New Issue
Block a user