mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 12:33:35 +01:00
Add setting for git commands to be logged in the git output
This commit is contained in:
@@ -12,7 +12,7 @@ import { EventEmitter } from 'events';
|
||||
import * as iconv from '@vscode/iconv-lite-umd';
|
||||
import * as filetype from 'file-type';
|
||||
import { assign, groupBy, IDisposable, toDisposable, dispose, mkdirp, readBytes, detectUnicodeEncoding, Encoding, onceEvent, splitInChunks, Limiter, Versions, isWindows } from './util';
|
||||
import { CancellationToken, Progress, Uri } from 'vscode';
|
||||
import { CancellationToken, ConfigurationChangeEvent, Progress, Uri, workspace } from 'vscode';
|
||||
import { detectEncoding } from './encoding';
|
||||
import { Ref, RefType, Branch, Remote, ForcePushMode, GitErrorCodes, LogOptions, Change, Status, CommitOptions, BranchQuery } from './api/git';
|
||||
import * as byline from 'byline';
|
||||
@@ -367,6 +367,7 @@ export class Git {
|
||||
readonly userAgent: string;
|
||||
readonly version: string;
|
||||
private env: any;
|
||||
private commandsToLog: string[] = [];
|
||||
|
||||
private _onOutput = new EventEmitter();
|
||||
get onOutput(): EventEmitter { return this._onOutput; }
|
||||
@@ -376,6 +377,18 @@ export class Git {
|
||||
this.version = options.version;
|
||||
this.userAgent = options.userAgent;
|
||||
this.env = options.env || {};
|
||||
|
||||
const onConfigurationChanged = (e?: ConfigurationChangeEvent) => {
|
||||
if (e !== undefined && !e.affectsConfiguration('git.commandsToLog')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const config = workspace.getConfiguration('git');
|
||||
this.commandsToLog = config.get<string[]>('commandsToLog', []);
|
||||
};
|
||||
|
||||
workspace.onDidChangeConfiguration(onConfigurationChanged, this);
|
||||
onConfigurationChanged();
|
||||
}
|
||||
|
||||
compareGitVersionTo(version: string): -1 | 0 | 1 {
|
||||
@@ -534,8 +547,15 @@ export class Git {
|
||||
const bufferResult = await exec(child, options.cancellationToken);
|
||||
|
||||
if (options.log !== false) {
|
||||
// command
|
||||
this.log(`> git ${args.join(' ')} [${Date.now() - startTime}ms]\n`);
|
||||
|
||||
// stdout
|
||||
if (args.length > 0 && this.commandsToLog.includes(args[0]) && bufferResult.stdout.length > 0) {
|
||||
this.log(`${bufferResult.stdout}\n`);
|
||||
}
|
||||
|
||||
// stderr
|
||||
if (bufferResult.stderr.length > 0) {
|
||||
this.log(`${bufferResult.stderr}\n`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user