Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(git): credential lookup for publish never opens a GCM sign-in window

reviewcbd08e76d603
diff --git a/src/core/git-service.publish-auth.test.ts b/src/core/git-service.publish-auth.test.ts
index 3c0c06f56..bb7ba232d 100644
--- a/src/core/git-service.publish-auth.test.ts
+++ b/src/core/git-service.publish-auth.test.ts
@@ -47,4 +47,15 @@ describe.skipIf(process.platform === 'win32')('GitService.publish — gh auth af
await expect(git.publish(dir, 'owner/repo', true)).resolves.toEqual({ ok: true, message: 'Published to GitHub.' })
expect(fs.readFileSync(path.join(dir, 'calls'), 'utf8').trim()).toBe('repo create owner/repo --private --source=. --push')
})
+
+ it('asks the git credential helper for a STORED token only (GCM_INTERACTIVE=never)', async () => {
+ // A credential helper that records the env it was run with and answers nothing.
+ const helper = path.join(dir, 'helper.sh')
+ fs.writeFileSync(helper, `#!/bin/sh\necho "gcm=$GCM_INTERACTIVE" >> '${dir}/helper-env'\nexit 0\n`, { mode: 0o755 })
+ fs.writeFileSync(path.join(dir, 'no-gitconfig'), `[credential]\n\thelper = ${helper}\n`)
+ vi.resetModules()
+ const { GitService } = await import('./git-service')
+ await expect(new GitService().publish(dir, 'owner/repo', true)).resolves.toMatchObject({ ok: false, needsAuth: true })
+ expect(fs.readFileSync(path.join(dir, 'helper-env'), 'utf8')).toContain('gcm=never')
+ })
})
diff --git a/src/core/git-service.ts b/src/core/git-service.ts
index 7081f39a7..cdf9a63ef 100644
--- a/src/core/git-service.ts
+++ b/src/core/git-service.ts
@@ -188,7 +188,15 @@ function parseNumstat(out: string): Map<string, { added: number; deleted: number
function githubTokenFromGitCredentials(cwd: string): Promise<string | null> {
return new Promise((resolve) => {
let out = ''
- const child = spawn('git', ['credential', 'fill'], { cwd: cwd || undefined, env: GIT_ENV })
+ // A STORED token only — never an interactive login. Git Credential Manager (the default helper
+ // in Git for Windows, optional on macOS/Linux) opens a GUI sign-in for an empty store, which
+ // `GIT_TERMINAL_PROMPT=0` does not suppress; Source Control retries publish every few seconds
+ // while the user runs `gh auth login` (renderer/lib/publishFallback), so without this every
+ // retry would stack another GCM window. Helpers other than GCM ignore the variable.
+ const child = spawn('git', ['credential', 'fill'], {
+ cwd: cwd || undefined,
+ env: { ...GIT_ENV, GCM_INTERACTIVE: 'never' }
+ })
const timer = setTimeout(() => child.kill('SIGKILL'), 5000)
child.stdout.on('data', (d) => {
out += d.toString()