瀏覽代碼

Fixes #2680 detects env shell for proper command

main
Eric Amodio 1 年之前
父節點
當前提交
493ab352ca
共有 2 個文件被更改,包括 10 次插入21 次删除
  1. +0
    -1
      src/constants.ts
  2. +10
    -20
      src/env/node/git/git.ts

+ 0
- 1
src/constants.ts 查看文件

@ -394,7 +394,6 @@ export type CoreConfiguration =
| 'http.proxySupport'
| 'http.proxyStrictSSL'
| 'search.exclude'
| 'terminal.integrated.defaultProfile.windows'
| 'workbench.editorAssociations'
| 'workbench.tree.renderIndentGuides';

+ 10
- 20
src/env/node/git/git.ts 查看文件

@ -3,9 +3,8 @@ import { spawn } from 'child_process';
import { accessSync } from 'fs';
import * as process from 'process';
import type { CancellationToken, OutputChannel } from 'vscode';
import { Uri, window, workspace } from 'vscode';
import { env, Uri, window, workspace } from 'vscode';
import { hrtime } from '@env/hrtime';
import type { CoreConfiguration } from '../../../constants';
import { GlyphChars } from '../../../constants';
import type { GitCommandOptions, GitSpawnOptions } from '../../../git/commandOptions';
import { GitErrorHandling } from '../../../git/commandOptions';
@ -25,14 +24,13 @@ import { Logger } from '../../../system/logger';
import { LogLevel, slowCallWarningThreshold } from '../../../system/logger.constants';
import { getLogScope } from '../../../system/logger.scope';
import { dirname, isAbsolute, isFolderGlob, joinPaths, normalizePath, splitPath } from '../../../system/path';
import { equalsIgnoreCase, getDurationMilliseconds } from '../../../system/string';
import { getDurationMilliseconds } from '../../../system/string';
import { getEditorCommand } from '../../../system/utils';
import { compare, fromString } from '../../../system/version';
import { ensureGitTerminal } from '../../../terminal';
import { isWindows } from '../platform';
import type { GitLocation } from './locator';
import type { RunOptions } from './shell';
import { fsExists, getWindowsShortPath, run, RunError } from './shell';
import { fsExists, isWindows, run, RunError } from './shell';
const emptyArray = Object.freeze([]) as unknown as any[];
const emptyObj = Object.freeze({});
@ -2071,23 +2069,15 @@ export class Git {
const parsedArgs = args.map(arg => (arg.startsWith('#') || /['();$|>&<]/.test(arg) ? `"${arg}"` : arg));
let text;
if (git.includes(' ') && isWindows) {
let shortenedPath = await getWindowsShortPath(git);
Logger.log(scope, `\u2022 using short Git path '${shortenedPath}' rather than '${git}'`);
if (git.includes(' ')) {
const shell = env.shell;
Logger.debug(scope, `\u2022 git path '${git}' contains spaces, detected shell: '${shell}'`);
if (shortenedPath.includes(' ')) {
const profile = configuration.getAny<CoreConfiguration, string | null>(
'terminal.integrated.defaultProfile.windows',
);
Logger.debug(scope, `\u2022 short path '${shortenedPath}' contains spaces, profile '${profile}'`);
shortenedPath = `${equalsIgnoreCase(profile, 'powershell') ? '& ' : ''}"${shortenedPath}"`;
}
text = `${shortenedPath} -C "${cwd}" ${coreEditorConfig}${command} ${parsedArgs.join(' ')}`;
text = `${
(isWindows ? /(pwsh|powershell)\.exe/i : /pwsh/i).test(shell) ? '&' : ''
} "${git}" -C "${cwd}" ${coreEditorConfig}${command} ${parsedArgs.join(' ')}`;
} else {
text = `${git.includes(' ') ? `"${git}"` : git} -C "${cwd}" ${coreEditorConfig}${command} ${parsedArgs.join(
' ',
)}`;
text = `${git} -C "${cwd}" ${coreEditorConfig}${command} ${parsedArgs.join(' ')}`;
}
Logger.log(scope, `\u2022 '${text}'`);

Loading…
取消
儲存