mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 01:37:20 +00:00
Add setting for git commands to be logged in the git output
This commit is contained in:
parent
a05cb7a87a
commit
e4cce8c6e8
3 changed files with 31 additions and 1 deletions
|
@ -2245,6 +2245,15 @@
|
|||
"scope": "resource",
|
||||
"default": 1,
|
||||
"markdownDescription": "%config.repositoryScanMaxDepth%"
|
||||
},
|
||||
"git.commandsToLog": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": [],
|
||||
"scope": "resource",
|
||||
"markdownDescription": "%config.commandsToLog%"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -162,6 +162,7 @@
|
|||
"config.ignoreSubmodules": "Ignore modifications to submodules in the file tree.",
|
||||
"config.ignoredRepositories": "List of git repositories to ignore.",
|
||||
"config.scanRepositories": "List of paths to search for git repositories in.",
|
||||
"config.commandsToLog": "List of git commands (ex: commit, push) that would have their `stdout` logged to the [git output](command:git.showOutput). If the git command has a client-side hook configured, the client-side hook's `stdout` will also be logged to the [git output](command:git.showOutput).",
|
||||
"config.showProgress": "Controls whether git actions should show progress.",
|
||||
"config.rebaseWhenSync": "Force git to use rebase when running the sync command.",
|
||||
"config.confirmEmptyCommits": "Always confirm the creation of empty commits for the 'Git: Commit Empty' command.",
|
||||
|
|
|
@ -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`);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue