diff --git a/apps/desktop/electron/desktop-plugin-install.ts b/apps/desktop/electron/desktop-plugin-install.ts index ebb8e1a3bd..ad6d5497da 100644 --- a/apps/desktop/electron/desktop-plugin-install.ts +++ b/apps/desktop/electron/desktop-plugin-install.ts @@ -273,6 +273,7 @@ function runGit(gitBin: string, args: string[], cwd?: string): Promise<{ code: n env: noninteractiveGitEnv(), stdio: ['ignore', 'ignore', 'pipe'] }) + const child = spawn(spec.command, spec.args, spec.options) let stderr = '' diff --git a/apps/desktop/electron/git-review-ops.ts b/apps/desktop/electron/git-review-ops.ts index 61c48578f3..03d3c8b46d 100644 --- a/apps/desktop/electron/git-review-ops.ts +++ b/apps/desktop/electron/git-review-ops.ts @@ -59,6 +59,7 @@ function gitFor(cwd, gitBin) { const binary = simpleGitBinary(gitBin, host) const binaryParts = Array.isArray(binary) ? binary : [binary] const unsafe = binaryParts.some(part => /\s/.test(part)) || Boolean(gitBin && /\s/.test(gitBin)) + const git = simpleGit({ baseDir: cwd, binary, diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts index cd1d80a235..32975bae9b 100644 --- a/apps/desktop/electron/main.ts +++ b/apps/desktop/electron/main.ts @@ -3108,6 +3108,7 @@ function runGit(args, options: any = {}): Promise<{ code: number; stdout: string const gitBinary = resolveGitBinary() const gitArgs = IS_WINDOWS ? ['-c', 'windows.appendAtomically=false', ...args] : args const host = IS_WINDOWS ? windowsGitHost(true) : null + const plan = planNoConsoleGitSpawn({ gitBin: gitBinary, args: gitArgs, diff --git a/apps/desktop/electron/no-console-git.test.ts b/apps/desktop/electron/no-console-git.test.ts index 6c52aae1f4..11c21042ed 100644 --- a/apps/desktop/electron/no-console-git.test.ts +++ b/apps/desktop/electron/no-console-git.test.ts @@ -124,6 +124,7 @@ test('host script forwards git argv unchanged and sets CREATE_NO_WINDOW', () => HERMES_GIT_NO_CONSOLE: '1' } }) + const parsed = JSON.parse(out) assert.deepEqual(parsed.argv, [gitBin, ...gitArgs]) diff --git a/apps/desktop/electron/no-console-git.ts b/apps/desktop/electron/no-console-git.ts index af383463f7..e969556651 100644 --- a/apps/desktop/electron/no-console-git.ts +++ b/apps/desktop/electron/no-console-git.ts @@ -73,28 +73,38 @@ export function resolveNoConsolePython({ roots?: string[] fileExists?: (candidate: string) => boolean }): string | null { - if (!isWindows) {return null} + if (!isWindows) { + return null + } const candidates: string[] = [] const override = env.HERMES_DESKTOP_PYTHON - if (override) {candidates.push(override)} + if (override) { + candidates.push(override) + } const hermesRoot = env.HERMES_DESKTOP_HERMES_ROOT const searchRoots = hermesRoot ? [hermesRoot, ...roots] : roots for (const root of searchRoots) { - if (!root) {continue} + if (!root) { + continue + } candidates.push(path.win32.join(root, '.venv', 'Scripts', 'python.exe')) candidates.push(path.win32.join(root, 'venv', 'Scripts', 'python.exe')) } for (const candidate of candidates) { - if (!candidate || isPythonW(candidate) || isWindowsAppsStub(candidate)) {continue} + if (!candidate || isPythonW(candidate) || isWindowsAppsStub(candidate)) { + continue + } try { - if (fileExists(candidate)) {return candidate} + if (fileExists(candidate)) { + return candidate + } } catch { continue } @@ -107,7 +117,9 @@ export function ensureNoConsoleGitScript(dir = os.tmpdir()) { const scriptPath = path.join(dir, 'hermes-no-console-git.py') try { - if (fs.readFileSync(scriptPath, 'utf8') === NO_CONSOLE_GIT_SCRIPT) {return scriptPath} + if (fs.readFileSync(scriptPath, 'utf8') === NO_CONSOLE_GIT_SCRIPT) { + return scriptPath + } } catch { // Missing or unreadable: rewrite below. } @@ -118,11 +130,15 @@ export function ensureNoConsoleGitScript(dir = os.tmpdir()) { } export function windowsGitHost(isWindows = process.platform === 'win32'): NoConsoleGitHost | null { - if (!isWindows) {return null} + if (!isWindows) { + return null + } const pythonBin = resolveNoConsolePython({ isWindows: true }) - if (!pythonBin) {return null} + if (!pythonBin) { + return null + } try { return { isWindows: true, pythonBin, scriptPath: ensureNoConsoleGitScript() } @@ -135,12 +151,16 @@ export function noConsoleGitEnv(base: NodeJS.ProcessEnv | undefined, gitBin: str const env: NodeJS.ProcessEnv = {} for (const [key, value] of Object.entries(base || {})) { - if (value !== undefined) {env[key] = value} + if (value !== undefined) { + env[key] = value + } } env.HERMES_GIT_ARGV0 = JSON.stringify(gitBin || 'git') - if (!env.GIT_TERMINAL_PROMPT) {env.GIT_TERMINAL_PROMPT = '0'} + if (!env.GIT_TERMINAL_PROMPT) { + env.GIT_TERMINAL_PROMPT = '0' + } return env } @@ -242,7 +262,9 @@ export function execGit( let settled = false const finish = (error?: Error, code: number | null = child.exitCode) => { - if (settled) {return} + if (settled) { + return + } settled = true @@ -272,12 +294,16 @@ export function execGit( stderr += chunk.toString() }) child.once('error', error => { - if (timer) {clearTimeout(timer)} + if (timer) { + clearTimeout(timer) + } finish(error) }) child.once('close', code => { - if (timer) {clearTimeout(timer)} + if (timer) { + clearTimeout(timer) + } finish(undefined, code) })