Compare commits
1 Commits
fix/issue-
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
632807d0ba |
@@ -111,7 +111,7 @@ import { BackgroundTasksDialog } from '../tasks/BackgroundTasksDialog.js';
|
||||
import { shouldHideTasksFooter } from '../tasks/taskStatusUtils.js';
|
||||
import { TeamsDialog } from '../teams/TeamsDialog.js';
|
||||
import VimTextInput from '../VimTextInput.js';
|
||||
import { getModeFromInput, getValueFromInput } from './inputModes.js';
|
||||
import { detectModeEntry, getModeFromInput, getValueFromInput } from './inputModes.js';
|
||||
import { FOOTER_TEMPORARY_STATUS_TIMEOUT, Notifications } from './Notifications.js';
|
||||
import PromptInputFooter from './PromptInputFooter.js';
|
||||
import type { SuggestionItem } from './PromptInputFooterSuggestions.js';
|
||||
@@ -878,24 +878,22 @@ function PromptInput({
|
||||
abortPromptSuggestion();
|
||||
abortSpeculation(setAppState);
|
||||
|
||||
// Check if this is a single character insertion at the start
|
||||
const isSingleCharInsertion = value.length === input.length + 1;
|
||||
const insertedAtStart = cursorOffset === 0;
|
||||
const mode = getModeFromInput(value);
|
||||
if (insertedAtStart && mode !== 'prompt') {
|
||||
if (isSingleCharInsertion) {
|
||||
onModeChange(mode);
|
||||
return;
|
||||
}
|
||||
// Multi-char insertion into empty input (e.g. tab-accepting "! gcloud auth login")
|
||||
if (input.length === 0) {
|
||||
onModeChange(mode);
|
||||
const valueWithoutMode = getValueFromInput(value).replaceAll('\t', ' ');
|
||||
pushToBuffer(input, cursorOffset, pastedContents);
|
||||
trackAndSetInput(valueWithoutMode);
|
||||
setCursorOffset(valueWithoutMode.length);
|
||||
return;
|
||||
}
|
||||
// Strip the mode character from the buffer when entering bash mode — the
|
||||
// mode itself is shown via the prompt prefix in the UI. Without this,
|
||||
// typing `!` into empty input would enter bash mode but leave the literal
|
||||
// `!` in the buffer (issue #662).
|
||||
const modeEntry = detectModeEntry({
|
||||
value,
|
||||
prevInputLength: input.length,
|
||||
cursorOffset,
|
||||
});
|
||||
if (modeEntry) {
|
||||
onModeChange(modeEntry.mode);
|
||||
const cleaned = modeEntry.strippedValue.replaceAll('\t', ' ');
|
||||
pushToBuffer(input, cursorOffset, pastedContents);
|
||||
trackAndSetInput(cleaned);
|
||||
setCursorOffset(cleaned.length);
|
||||
return;
|
||||
}
|
||||
const processedValue = value.replaceAll('\t', ' ');
|
||||
|
||||
|
||||
104
src/components/PromptInput/inputModes.test.ts
Normal file
104
src/components/PromptInput/inputModes.test.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import { describe, expect, it } from 'bun:test'
|
||||
import {
|
||||
detectModeEntry,
|
||||
getModeFromInput,
|
||||
getValueFromInput,
|
||||
isInputModeCharacter,
|
||||
prependModeCharacterToInput,
|
||||
} from './inputModes.js'
|
||||
|
||||
describe('inputModes', () => {
|
||||
describe('getModeFromInput', () => {
|
||||
it('returns bash mode for input starting with !', () => {
|
||||
expect(getModeFromInput('!')).toBe('bash')
|
||||
expect(getModeFromInput('!ls')).toBe('bash')
|
||||
})
|
||||
|
||||
it('returns prompt mode for non-bash input', () => {
|
||||
expect(getModeFromInput('')).toBe('prompt')
|
||||
expect(getModeFromInput('hello')).toBe('prompt')
|
||||
expect(getModeFromInput(' !')).toBe('prompt')
|
||||
})
|
||||
})
|
||||
|
||||
describe('getValueFromInput', () => {
|
||||
it('strips the leading ! when entering bash mode', () => {
|
||||
expect(getValueFromInput('!')).toBe('')
|
||||
expect(getValueFromInput('!ls -la')).toBe('ls -la')
|
||||
})
|
||||
|
||||
it('returns input unchanged in prompt mode', () => {
|
||||
expect(getValueFromInput('')).toBe('')
|
||||
expect(getValueFromInput('hello')).toBe('hello')
|
||||
})
|
||||
})
|
||||
|
||||
describe('isInputModeCharacter', () => {
|
||||
it('returns true only for the bare ! character', () => {
|
||||
expect(isInputModeCharacter('!')).toBe(true)
|
||||
expect(isInputModeCharacter('!ls')).toBe(false)
|
||||
expect(isInputModeCharacter('')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('prependModeCharacterToInput', () => {
|
||||
it('prepends ! when mode is bash', () => {
|
||||
expect(prependModeCharacterToInput('ls', 'bash')).toBe('!ls')
|
||||
expect(prependModeCharacterToInput('', 'bash')).toBe('!')
|
||||
})
|
||||
|
||||
it('returns input unchanged in prompt mode', () => {
|
||||
expect(prependModeCharacterToInput('hello', 'prompt')).toBe('hello')
|
||||
})
|
||||
})
|
||||
|
||||
describe('detectModeEntry', () => {
|
||||
// Regression for #662 — typing `!` into empty input must switch to bash
|
||||
// mode AND yield an empty stripped buffer. Before the fix the single-char
|
||||
// path returned without stripping, leaving `!` visible in the buffer.
|
||||
it('strips the mode character when typing ! into empty input', () => {
|
||||
expect(
|
||||
detectModeEntry({ value: '!', prevInputLength: 0, cursorOffset: 0 }),
|
||||
).toEqual({ mode: 'bash', strippedValue: '' })
|
||||
})
|
||||
|
||||
it('strips the mode character when pasting !cmd into empty input', () => {
|
||||
expect(
|
||||
detectModeEntry({ value: '!ls -la', prevInputLength: 0, cursorOffset: 0 }),
|
||||
).toEqual({ mode: 'bash', strippedValue: 'ls -la' })
|
||||
})
|
||||
|
||||
it('returns null when the cursor is not at the start', () => {
|
||||
expect(
|
||||
detectModeEntry({ value: '!', prevInputLength: 0, cursorOffset: 1 }),
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('returns null when the value does not start with !', () => {
|
||||
expect(
|
||||
detectModeEntry({ value: 'hello', prevInputLength: 0, cursorOffset: 0 }),
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('returns null when typing ! after existing text', () => {
|
||||
// value="ab!" with prevInputLength=2 is a single-char insertion but does
|
||||
// not start with ! — getModeFromInput returns 'prompt'.
|
||||
expect(
|
||||
detectModeEntry({ value: 'ab!', prevInputLength: 2, cursorOffset: 0 }),
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('returns null when prepending ! to non-empty existing text', () => {
|
||||
// Single-char insertion at start that produces "!ab" from "ab" — value
|
||||
// length is 3, prevInputLength is 2, so isSingleCharInsertion is true
|
||||
// and isMultiCharIntoEmpty is false. We accept the mode change here so
|
||||
// that typing ! at the start of existing text still toggles mode.
|
||||
const result = detectModeEntry({
|
||||
value: '!ab',
|
||||
prevInputLength: 2,
|
||||
cursorOffset: 0,
|
||||
})
|
||||
expect(result).toEqual({ mode: 'bash', strippedValue: 'ab' })
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -31,3 +31,30 @@ export function getValueFromInput(input: string): string {
|
||||
export function isInputModeCharacter(input: string): boolean {
|
||||
return input === '!'
|
||||
}
|
||||
|
||||
export type ModeEntryDecision = {
|
||||
mode: HistoryMode
|
||||
strippedValue: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide whether an onChange `value` should switch the input mode (e.g.
|
||||
* `prompt` → `bash`) and what the stripped buffer value should be.
|
||||
*
|
||||
* Returns null when no mode change applies. Returns a decision otherwise so
|
||||
* callers run a single update path — no separate single-char vs multi-char
|
||||
* branches that can drift apart.
|
||||
*/
|
||||
export function detectModeEntry(args: {
|
||||
value: string
|
||||
prevInputLength: number
|
||||
cursorOffset: number
|
||||
}): ModeEntryDecision | null {
|
||||
if (args.cursorOffset !== 0) return null
|
||||
const mode = getModeFromInput(args.value)
|
||||
if (mode === 'prompt') return null
|
||||
const isSingleCharInsertion = args.value.length === args.prevInputLength + 1
|
||||
const isMultiCharIntoEmpty = args.prevInputLength === 0
|
||||
if (!isSingleCharInsertion && !isMultiCharIntoEmpty) return null
|
||||
return { mode, strippedValue: getValueFromInput(args.value) }
|
||||
}
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
__resetGitEnvWarningForTesting,
|
||||
buildGitChildEnv,
|
||||
sanitizeEnvForGit,
|
||||
} from './gitEnv.js'
|
||||
|
||||
describe('sanitizeEnvForGit', () => {
|
||||
test('drops values containing LF', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
GOOD: 'value',
|
||||
BAD_NEWLINE: 'line1\nline2',
|
||||
})
|
||||
expect(result.env).toEqual({ GOOD: 'value' })
|
||||
expect(result.dropped).toEqual(['BAD_NEWLINE'])
|
||||
})
|
||||
|
||||
test('drops values containing CR', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
GOOD: 'value',
|
||||
BAD_CR: 'value\r',
|
||||
})
|
||||
expect(result.dropped).toEqual(['BAD_CR'])
|
||||
})
|
||||
|
||||
test('drops values containing NUL', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
GOOD: 'value',
|
||||
BAD_NUL: 'a\0b',
|
||||
})
|
||||
expect(result.dropped).toEqual(['BAD_NUL'])
|
||||
})
|
||||
|
||||
test('drops keys whose name itself contains a control character', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
'BAD\nKEY': 'safe-value',
|
||||
GOOD: 'value',
|
||||
})
|
||||
expect(result.env).toEqual({ GOOD: 'value' })
|
||||
expect(result.dropped).toEqual(['BAD\nKEY'])
|
||||
})
|
||||
|
||||
test('skips entries explicitly set to undefined without listing them as dropped', () => {
|
||||
const result = sanitizeEnvForGit({
|
||||
GOOD: 'value',
|
||||
MAYBE: undefined,
|
||||
})
|
||||
expect(result.env).toEqual({ GOOD: 'value' })
|
||||
expect(result.dropped).toEqual([])
|
||||
})
|
||||
|
||||
test('returns input unchanged when nothing is unsafe', () => {
|
||||
const env = { PATH: '/usr/bin:/bin', HOME: '/home/user', GIT_TERMINAL_PROMPT: '0' }
|
||||
const result = sanitizeEnvForGit(env)
|
||||
expect(result.env).toEqual(env)
|
||||
expect(result.dropped).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildGitChildEnv', () => {
|
||||
const ORIGINAL_BAD_KEY = 'OPENCLAUDE_TEST_BAD_ENV_FOR_GIT'
|
||||
let originalValue: string | undefined
|
||||
|
||||
beforeEach(() => {
|
||||
__resetGitEnvWarningForTesting()
|
||||
originalValue = process.env[ORIGINAL_BAD_KEY]
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (originalValue === undefined) {
|
||||
delete process.env[ORIGINAL_BAD_KEY]
|
||||
} else {
|
||||
process.env[ORIGINAL_BAD_KEY] = originalValue
|
||||
}
|
||||
})
|
||||
|
||||
test('always sets the no-prompt overrides', () => {
|
||||
const env = buildGitChildEnv()
|
||||
expect(env.GIT_TERMINAL_PROMPT).toBe('0')
|
||||
expect(env.GIT_ASKPASS).toBe('')
|
||||
})
|
||||
|
||||
test('drops process.env values containing control characters (issue #751)', () => {
|
||||
process.env[ORIGINAL_BAD_KEY] = 'paste-with-newline\n'
|
||||
const env = buildGitChildEnv()
|
||||
expect(env[ORIGINAL_BAD_KEY]).toBeUndefined()
|
||||
expect(env.GIT_TERMINAL_PROMPT).toBe('0')
|
||||
})
|
||||
|
||||
test('caller extras override process.env and the no-prompt defaults', () => {
|
||||
const env = buildGitChildEnv({
|
||||
GIT_TERMINAL_PROMPT: '1',
|
||||
CUSTOM_KEY: 'custom-value',
|
||||
})
|
||||
expect(env.GIT_TERMINAL_PROMPT).toBe('1')
|
||||
expect(env.CUSTOM_KEY).toBe('custom-value')
|
||||
})
|
||||
|
||||
test('caller-provided unsafe extras are also dropped', () => {
|
||||
const env = buildGitChildEnv({ EXTRA_BAD: 'a\rb' })
|
||||
expect(env.EXTRA_BAD).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -1,70 +0,0 @@
|
||||
import { logForDebugging } from '../debug.js'
|
||||
|
||||
/**
|
||||
* Git 2.30+ refuses to start when any environment value contains a NUL,
|
||||
* CR, or LF character ("Unsafe environment: control characters are not
|
||||
* allowed in values"). User shells frequently leak such values — a
|
||||
* copy-pasted API key with a trailing newline, or a terminal-set
|
||||
* variable with embedded escape sequences — which would otherwise break
|
||||
* every plugin clone or pull. We drop offending entries before forwarding
|
||||
* the environment to git.
|
||||
*/
|
||||
const GIT_UNSAFE_VALUE_RE = /[\0\r\n]/
|
||||
|
||||
const GIT_NO_PROMPT_ENV = {
|
||||
GIT_TERMINAL_PROMPT: '0', // Prevent terminal credential prompts
|
||||
GIT_ASKPASS: '', // Disable askpass GUI programs
|
||||
}
|
||||
|
||||
let warnedAboutDroppedEnvKeys = false
|
||||
|
||||
/**
|
||||
* Returns a copy of `env` with any entries whose key OR value contains
|
||||
* a NUL/CR/LF removed. The list of dropped key names is returned so
|
||||
* callers can log it without exposing the (possibly secret) values.
|
||||
*/
|
||||
export function sanitizeEnvForGit(
|
||||
env: NodeJS.ProcessEnv,
|
||||
): { env: NodeJS.ProcessEnv; dropped: string[] } {
|
||||
const sanitized: NodeJS.ProcessEnv = {}
|
||||
const dropped: string[] = []
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
if (value === undefined) continue
|
||||
if (GIT_UNSAFE_VALUE_RE.test(key) || GIT_UNSAFE_VALUE_RE.test(value)) {
|
||||
dropped.push(key)
|
||||
continue
|
||||
}
|
||||
sanitized[key] = value
|
||||
}
|
||||
return { env: sanitized, dropped }
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the environment object passed to a git child process. Merges
|
||||
* `process.env` with the no-prompt overrides and any caller extras,
|
||||
* then strips entries that would trigger git's unsafe-value check. The
|
||||
* first batch of dropped key names is logged once per process so the
|
||||
* user can clean them up in their shell.
|
||||
*/
|
||||
export function buildGitChildEnv(
|
||||
extras?: NodeJS.ProcessEnv,
|
||||
): NodeJS.ProcessEnv {
|
||||
const merged = { ...process.env, ...GIT_NO_PROMPT_ENV, ...(extras ?? {}) }
|
||||
const { env, dropped } = sanitizeEnvForGit(merged)
|
||||
if (dropped.length > 0 && !warnedAboutDroppedEnvKeys) {
|
||||
warnedAboutDroppedEnvKeys = true
|
||||
logForDebugging(
|
||||
`git child env: dropped ${dropped.length} key(s) containing control characters: ${dropped.join(', ')}. Git 2.30+ rejects them; clean these up in your shell to forward them to git.`,
|
||||
{ level: 'warn' },
|
||||
)
|
||||
}
|
||||
return env
|
||||
}
|
||||
|
||||
/**
|
||||
* Test-only escape hatch that resets the once-per-process warning flag
|
||||
* so unit tests can exercise the warning path repeatedly.
|
||||
*/
|
||||
export function __resetGitEnvWarningForTesting(): void {
|
||||
warnedAboutDroppedEnvKeys = false
|
||||
}
|
||||
@@ -53,7 +53,6 @@ import {
|
||||
getAddDirExtraMarketplaces,
|
||||
} from './addDirPluginSettings.js'
|
||||
import { markPluginVersionOrphaned } from './cacheUtils.js'
|
||||
import { buildGitChildEnv } from './gitEnv.js'
|
||||
import { classifyFetchError, logPluginFetch } from './fetchTelemetry.js'
|
||||
import { removeAllPluginsForMarketplace } from './installedPluginsManager.js'
|
||||
import {
|
||||
@@ -507,6 +506,11 @@ function seedDirFor(installLocation: string): string | undefined {
|
||||
* Provides helpful error messages for common failure scenarios.
|
||||
* If a ref is specified, fetches and checks out that specific branch or tag.
|
||||
*/
|
||||
// Environment variables to prevent git from prompting for credentials
|
||||
const GIT_NO_PROMPT_ENV = {
|
||||
GIT_TERMINAL_PROMPT: '0', // Prevent terminal credential prompts
|
||||
GIT_ASKPASS: '', // Disable askpass GUI programs
|
||||
}
|
||||
|
||||
const DEFAULT_PLUGIN_GIT_TIMEOUT_MS = 120 * 1000
|
||||
|
||||
@@ -527,7 +531,7 @@ export async function gitPull(
|
||||
options?: { disableCredentialHelper?: boolean; sparsePaths?: string[] },
|
||||
): Promise<{ code: number; stderr: string }> {
|
||||
logForDebugging(`git pull: cwd=${cwd} ref=${ref ?? 'default'}`)
|
||||
const env = buildGitChildEnv()
|
||||
const env = { ...process.env, ...GIT_NO_PROMPT_ENV }
|
||||
const baseArgs = ['-c', 'core.hooksPath=/dev/null']
|
||||
const credentialArgs = options?.disableCredentialHelper
|
||||
? ['-c', 'credential.helper=']
|
||||
@@ -840,7 +844,7 @@ export async function gitClone(
|
||||
const result = await execFileNoThrowWithCwd(gitExe(), args, {
|
||||
timeout: timeoutMs,
|
||||
stdin: 'ignore',
|
||||
env: buildGitChildEnv(),
|
||||
env: { ...process.env, ...GIT_NO_PROMPT_ENV },
|
||||
})
|
||||
|
||||
// Scrub credentials from execa's error/stderr fields before any logging or
|
||||
@@ -866,7 +870,7 @@ export async function gitClone(
|
||||
cwd: targetPath,
|
||||
timeout: timeoutMs,
|
||||
stdin: 'ignore',
|
||||
env: buildGitChildEnv(),
|
||||
env: { ...process.env, ...GIT_NO_PROMPT_ENV },
|
||||
},
|
||||
)
|
||||
if (sparseResult.code !== 0) {
|
||||
@@ -885,7 +889,7 @@ export async function gitClone(
|
||||
cwd: targetPath,
|
||||
timeout: timeoutMs,
|
||||
stdin: 'ignore',
|
||||
env: buildGitChildEnv(),
|
||||
env: { ...process.env, ...GIT_NO_PROMPT_ENV },
|
||||
},
|
||||
)
|
||||
if (checkoutResult.code !== 0) {
|
||||
@@ -1036,7 +1040,7 @@ export async function reconcileSparseCheckout(
|
||||
cwd: string,
|
||||
sparsePaths: string[] | undefined,
|
||||
): Promise<{ code: number; stderr: string }> {
|
||||
const env = buildGitChildEnv()
|
||||
const env = { ...process.env, ...GIT_NO_PROMPT_ENV }
|
||||
|
||||
if (sparsePaths && sparsePaths.length > 0) {
|
||||
return execFileNoThrowWithCwd(
|
||||
|
||||
@@ -87,7 +87,6 @@ import { getAddDirEnabledPlugins } from './addDirPluginSettings.js'
|
||||
import { verifyAndDemote } from './dependencyResolver.js'
|
||||
import { classifyFetchError, logPluginFetch } from './fetchTelemetry.js'
|
||||
import { checkGitAvailable } from './gitAvailability.js'
|
||||
import { buildGitChildEnv } from './gitEnv.js'
|
||||
import { getInMemoryInstalledPlugins } from './installedPluginsManager.js'
|
||||
import { getManagedPluginNames } from './managedPlugins.js'
|
||||
import {
|
||||
@@ -561,9 +560,7 @@ export async function gitClone(
|
||||
args.push(gitUrl, targetPath)
|
||||
|
||||
const cloneStarted = performance.now()
|
||||
const cloneResult = await execFileNoThrow(gitExe(), args, {
|
||||
env: buildGitChildEnv(),
|
||||
})
|
||||
const cloneResult = await execFileNoThrow(gitExe(), args)
|
||||
|
||||
if (cloneResult.code !== 0) {
|
||||
logPluginFetch(
|
||||
@@ -582,7 +579,7 @@ export async function gitClone(
|
||||
const shallowFetchResult = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['fetch', '--depth', '1', 'origin', sha],
|
||||
{ cwd: targetPath, env: buildGitChildEnv() },
|
||||
{ cwd: targetPath },
|
||||
)
|
||||
|
||||
if (shallowFetchResult.code !== 0) {
|
||||
@@ -594,7 +591,7 @@ export async function gitClone(
|
||||
const unshallowResult = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['fetch', '--unshallow'],
|
||||
{ cwd: targetPath, env: buildGitChildEnv() },
|
||||
{ cwd: targetPath },
|
||||
)
|
||||
|
||||
if (unshallowResult.code !== 0) {
|
||||
@@ -615,7 +612,7 @@ export async function gitClone(
|
||||
const checkoutResult = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['checkout', sha],
|
||||
{ cwd: targetPath, env: buildGitChildEnv() },
|
||||
{ cwd: targetPath },
|
||||
)
|
||||
|
||||
if (checkoutResult.code !== 0) {
|
||||
@@ -748,9 +745,7 @@ export async function installFromGitSubdir(
|
||||
}
|
||||
cloneArgs.push(gitUrl, cloneDir)
|
||||
|
||||
const cloneResult = await execFileNoThrow(gitExe(), cloneArgs, {
|
||||
env: buildGitChildEnv(),
|
||||
})
|
||||
const cloneResult = await execFileNoThrow(gitExe(), cloneArgs)
|
||||
if (cloneResult.code !== 0) {
|
||||
throw new Error(
|
||||
`Failed to clone repository for git-subdir source: ${cloneResult.stderr}`,
|
||||
@@ -761,7 +756,7 @@ export async function installFromGitSubdir(
|
||||
const sparseResult = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['sparse-checkout', 'set', '--cone', '--', subdirPath],
|
||||
{ cwd: cloneDir, env: buildGitChildEnv() },
|
||||
{ cwd: cloneDir },
|
||||
)
|
||||
if (sparseResult.code !== 0) {
|
||||
throw new Error(
|
||||
@@ -780,7 +775,7 @@ export async function installFromGitSubdir(
|
||||
const fetchSha = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['fetch', '--depth', '1', 'origin', sha],
|
||||
{ cwd: cloneDir, env: buildGitChildEnv() },
|
||||
{ cwd: cloneDir },
|
||||
)
|
||||
if (fetchSha.code !== 0) {
|
||||
logForDebugging(
|
||||
@@ -789,7 +784,7 @@ export async function installFromGitSubdir(
|
||||
const unshallow = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['fetch', '--unshallow'],
|
||||
{ cwd: cloneDir, env: buildGitChildEnv() },
|
||||
{ cwd: cloneDir },
|
||||
)
|
||||
if (unshallow.code !== 0) {
|
||||
throw new Error(`Failed to fetch commit ${sha}: ${unshallow.stderr}`)
|
||||
@@ -798,7 +793,7 @@ export async function installFromGitSubdir(
|
||||
const checkout = await execFileNoThrowWithCwd(
|
||||
gitExe(),
|
||||
['checkout', sha],
|
||||
{ cwd: cloneDir, env: buildGitChildEnv() },
|
||||
{ cwd: cloneDir },
|
||||
)
|
||||
if (checkout.code !== 0) {
|
||||
throw new Error(`Failed to checkout commit ${sha}: ${checkout.stderr}`)
|
||||
@@ -813,11 +808,9 @@ export async function installFromGitSubdir(
|
||||
const [checkout, revParse] = await Promise.all([
|
||||
execFileNoThrowWithCwd(gitExe(), ['checkout', 'HEAD'], {
|
||||
cwd: cloneDir,
|
||||
env: buildGitChildEnv(),
|
||||
}),
|
||||
execFileNoThrowWithCwd(gitExe(), ['rev-parse', 'HEAD'], {
|
||||
cwd: cloneDir,
|
||||
env: buildGitChildEnv(),
|
||||
}),
|
||||
])
|
||||
if (checkout.code !== 0) {
|
||||
|
||||
Reference in New Issue
Block a user