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) <noreply@anthropic.com>
This commit is contained in:
TÂCHES 2026-03-17 18:01:38 -06:00 committed by GitHub
parent 1ae7b07237
commit 46dc70f4f6
3 changed files with 14 additions and 15 deletions

View file

@ -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: "",
};

View file

@ -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.

View file

@ -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 "";