From 46dc70f4f657f400cbd1a3f56c10ee2729e50b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=82CHES?= Date: Tue, 17 Mar 2026 18:01:38 -0600 Subject: [PATCH] fix(gsd): add GIT_NO_PROMPT_ENV to gitFileExec and deduplicate constant (#1006) gitFileExec() was missing the GIT_NO_PROMPT_ENV env overlay, which meant git could prompt for credentials and hang the process on write operations (add, commit, revert, checkout). Extract the shared constant into git-constants.ts to avoid duplication between git-service.ts and native-git-bridge.ts. Co-authored-by: Claude Opus 4.6 (1M context) --- src/resources/extensions/gsd/git-constants.ts | 11 +++++++++++ src/resources/extensions/gsd/git-service.ts | 8 +------- src/resources/extensions/gsd/native-git-bridge.ts | 10 ++-------- 3 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 src/resources/extensions/gsd/git-constants.ts diff --git a/src/resources/extensions/gsd/git-constants.ts b/src/resources/extensions/gsd/git-constants.ts new file mode 100644 index 000000000..7213798ca --- /dev/null +++ b/src/resources/extensions/gsd/git-constants.ts @@ -0,0 +1,11 @@ +/** + * Shared git constants used across git-service and native-git-bridge. + */ + +/** Env overlay that suppresses interactive git credential prompts and git-svn noise. */ +export const GIT_NO_PROMPT_ENV = { + ...process.env, + GIT_TERMINAL_PROMPT: "0", + GIT_ASKPASS: "", + GIT_SVN_ID: "", +}; diff --git a/src/resources/extensions/gsd/git-service.ts b/src/resources/extensions/gsd/git-service.ts index cb0e6a5d1..97e39ef34 100644 --- a/src/resources/extensions/gsd/git-service.ts +++ b/src/resources/extensions/gsd/git-service.ts @@ -11,6 +11,7 @@ import { execFileSync, execSync } from "node:child_process"; import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { join } from "node:path"; +import { GIT_NO_PROMPT_ENV } from "./git-constants.js"; import { detectWorktreeName, @@ -254,13 +255,6 @@ export function writeIntegrationBranch(basePath: string, milestoneId: string, br // ─── Git Helper ──────────────────────────────────────────────────────────── -/** Env overlay that suppresses interactive git credential prompts and git-svn noise. */ -const GIT_NO_PROMPT_ENV = { - ...process.env, - GIT_TERMINAL_PROMPT: "0", - GIT_ASKPASS: "", - GIT_SVN_ID: "", -}; /** * Strip git-svn noise from error messages. diff --git a/src/resources/extensions/gsd/native-git-bridge.ts b/src/resources/extensions/gsd/native-git-bridge.ts index 0ce89662b..dd0958d53 100644 --- a/src/resources/extensions/gsd/native-git-bridge.ts +++ b/src/resources/extensions/gsd/native-git-bridge.ts @@ -9,14 +9,7 @@ import { execSync, execFileSync } from "node:child_process"; import { existsSync, readFileSync, unlinkSync, rmSync } from "node:fs"; import { join } from "node:path"; import { GSDError, GSD_GIT_ERROR } from "./errors.js"; - -/** Env overlay that suppresses interactive git credential prompts and git-svn noise. */ -const GIT_NO_PROMPT_ENV = { - ...process.env, - GIT_TERMINAL_PROMPT: "0", - GIT_ASKPASS: "", - GIT_SVN_ID: "", -}; +import { GIT_NO_PROMPT_ENV } from "./git-constants.js"; // Issue #453: keep auto-mode bookkeeping on the stable git CLI path unless a // caller explicitly opts into the native helper. @@ -160,6 +153,7 @@ function gitFileExec(basePath: string, args: string[], allowFailure = false): st cwd: basePath, stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8", + env: GIT_NO_PROMPT_ENV, }).trim(); } catch { if (allowFailure) return "";