fix(git): pass allowUnsafeCredentialHelper for token identity switching (#3383)

simple-git 3.35/3.36 moved its unsafe-config blocklist into
@simple-git/argv-parser and expanded it to include credential.helper.
setLocalIdentity already opted in for the SSH branch (core.sshCommand)
via createGit({ allowUnsafeSshCommand: true }), but the token branch
(addConfig("credential.helper", "store")) was left without the matching
opt-in, so switching to a token-auth identity throws:

  Configuring credential.helper is not permitted without enabling
  allowUnsafeCredentialHelper

Forward a new allowUnsafeCredentialHelper option through createGit and
enable it in setLocalIdentity alongside the existing SSH opt-in. Cover
the token branch (and the token -> SSH cleanup) with tests mirroring
the existing SSH case.
This commit is contained in:
SRnChito
2026-09-07 20:26:38 +03:00
committed by GitHub
parent cf02d405c6
commit 0459c8418b
2 changed files with 40 additions and 4 deletions
+5 -4
View File
@@ -352,7 +352,7 @@ const buildGitEnv = async () => {
return env;
};
const createGit = async (directory, { allowUnsafeSshCommand = false } = {}) => {
const createGit = async (directory, { allowUnsafeSshCommand = false, allowUnsafeCredentialHelper = false } = {}) => {
const env = await buildGitEnv();
const spawnOptions = { windowsHide: true };
const binary = getGitBinary();
@@ -360,8 +360,9 @@ const createGit = async (directory, { allowUnsafeSshCommand = false } = {}) => {
const unsafe = hasCustomBinary || allowUnsafeSshCommand
? {
...(hasCustomBinary && { allowUnsafeCustomBinary: true }),
...(allowUnsafeSshCommand && { allowUnsafeSshCommand: true }),
}
...(allowUnsafeSshCommand && { allowUnsafeSshCommand: true }),
...(allowUnsafeCredentialHelper && { allowUnsafeCredentialHelper: true }),
}
: undefined;
// Always pin simple-git to an explicit working directory. Omitting baseDir
// makes simple-git use process.cwd(), which breaks when the OpenChamber
@@ -2146,7 +2147,7 @@ export async function hasLocalIdentity(directory) {
}
export async function setLocalIdentity(directory, profile) {
const git = await createGit(directory, { allowUnsafeSshCommand: true });
const git = await createGit(directory, { allowUnsafeSshCommand: true, allowUnsafeCredentialHelper: true });
try {