diff --git a/src/git/git.ts b/src/git/git.ts index 138871a..d2f5a4f 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -53,10 +53,6 @@ const pendingCommands: Map> = new Map(); async function gitCommandCore(options: CommandOptions & { readonly correlationKey?: string }, ...args: any[]): Promise { const start = process.hrtime(); - // Fixes https://github.com/eamodio/vscode-gitlens/issues/73 & https://github.com/eamodio/vscode-gitlens/issues/161 - // See https://stackoverflow.com/questions/4144417/how-to-handle-asian-characters-in-file-names-in-git-on-os-x - args.splice(0, 0, '-c', 'core.quotepath=false', '-c', 'color.ui=false'); - const { correlationKey, ...opts } = options; const encoding = options.encoding || 'utf8'; @@ -68,11 +64,16 @@ async function gitCommandCore(options: CommandOptions & { readonly correlationKe env: { ...(options.env || process.env), GCM_INTERACTIVE: 'NEVER', GCM_PRESERVE_CREDS: 'TRUE' } } as CommandOptions; - const command = `(${runOpts.cwd}${correlationKey !== undefined ? correlationKey : ''}): git ${args.join(' ')}`; + const gitCommand = `git ${args.join(' ')}`; + const command = `(${runOpts.cwd}${correlationKey !== undefined ? correlationKey : ''}): ${gitCommand}`; let promise = pendingCommands.get(command); if (promise === undefined) { Logger.log(`Running${command}`); + // Fixes https://github.com/eamodio/vscode-gitlens/issues/73 & https://github.com/eamodio/vscode-gitlens/issues/161 + // See https://stackoverflow.com/questions/4144417/how-to-handle-asian-characters-in-file-names-in-git-on-os-x + args.splice(0, 0, '-c', 'core.quotepath=false', '-c', 'color.ui=false'); + promise = runCommand(git.path, args, runOpts); pendingCommands.set(command, promise); @@ -89,7 +90,10 @@ async function gitCommandCore(options: CommandOptions & { readonly correlationKe pendingCommands.delete(command); const duration = process.hrtime(start); - Logger.log(`Completed${command} in ${(duration[0] * 1000) + Math.floor(duration[1] / 1000000)} ms`); + const completedIn = `in ${(duration[0] * 1000) + Math.floor(duration[1] / 1000000)} ms`; + + Logger.log(`Completed${command} ${completedIn}`); + Logger.logGitCommand(`${gitCommand} ${completedIn}`, runOpts.cwd!); } if (encoding === 'utf8' || encoding === 'binary') return data; diff --git a/src/logger.ts b/src/logger.ts index 6571e1b..e73bfea 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -77,4 +77,15 @@ export class Logger { const now = new Date(); return `[${now.toISOString().replace(/T/, ' ').replace(/\..+/, '')}:${('00' + now.getUTCMilliseconds()).slice(-3)}]`; } + + static gitOutput: OutputChannel | undefined; + + static logGitCommand(command: string, cwd: string): void { + if (!this.debug) return; + + if (this.gitOutput === undefined) { + this.gitOutput = window.createOutputChannel(`${ExtensionOutputChannelName} (Git)`); + } + this.gitOutput.appendLine(`${this.timestamp} ${command} (${cwd})`); + } } \ No newline at end of file