mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
@@ -250,6 +250,7 @@ export class GitError {
|
||||
export interface IGitOptions {
|
||||
gitPath: string;
|
||||
version: string;
|
||||
env?: any;
|
||||
}
|
||||
|
||||
export const GitErrorCodes = {
|
||||
@@ -276,6 +277,7 @@ export class Git {
|
||||
|
||||
private gitPath: string;
|
||||
private version: string;
|
||||
private env: any;
|
||||
|
||||
private _onOutput = new EventEmitter<string>();
|
||||
get onOutput(): Event<string> { return this._onOutput.event; }
|
||||
@@ -283,10 +285,11 @@ export class Git {
|
||||
constructor(options: IGitOptions) {
|
||||
this.gitPath = options.gitPath;
|
||||
this.version = options.version;
|
||||
this.env = options.env || {};
|
||||
}
|
||||
|
||||
open(repository: string, env: any = {}): Repository {
|
||||
return new Repository(this, repository, env);
|
||||
open(repository: string): Repository {
|
||||
return new Repository(this, repository);
|
||||
}
|
||||
|
||||
async init(repository: string): Promise<void> {
|
||||
@@ -374,7 +377,7 @@ export class Git {
|
||||
options.stdio = ['ignore', null, null]; // Unless provided, ignore stdin and leave default streams for stdout and stderr
|
||||
}
|
||||
|
||||
options.env = assign({}, process.env, options.env || {}, {
|
||||
options.env = assign({}, process.env, this.env, options.env || {}, {
|
||||
VSCODE_GIT_COMMAND: args[0],
|
||||
LC_ALL: 'en_US',
|
||||
LANG: 'en_US.UTF-8'
|
||||
@@ -401,8 +404,7 @@ export class Repository {
|
||||
|
||||
constructor(
|
||||
private _git: Git,
|
||||
private repositoryRoot: string,
|
||||
private env: any = {}
|
||||
private repositoryRoot: string
|
||||
) { }
|
||||
|
||||
get git(): Git {
|
||||
@@ -415,23 +417,14 @@ export class Repository {
|
||||
|
||||
// TODO@Joao: rename to exec
|
||||
async run(args: string[], options: any = {}): Promise<IExecutionResult> {
|
||||
options.env = assign({}, options.env || {});
|
||||
options.env = assign(options.env, this.env);
|
||||
|
||||
return await this.git.exec(this.repositoryRoot, args, options);
|
||||
}
|
||||
|
||||
stream(args: string[], options: any = {}): cp.ChildProcess {
|
||||
options.env = assign({}, options.env || {});
|
||||
options.env = assign(options.env, this.env);
|
||||
|
||||
return this.git.stream(this.repositoryRoot, args, options);
|
||||
}
|
||||
|
||||
spawn(args: string[], options: any = {}): cp.ChildProcess {
|
||||
options.env = assign({}, options.env || {});
|
||||
options.env = assign(options.env, this.env);
|
||||
|
||||
return this.git.spawn(args, options);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user