fix(cli): strip -y/--fgm from extraArgs to prevent git commit conflict

Same class of bug as the -c/--context fix: these flags could leak
into extraArgs and be forwarded to the internal `git commit` call,
causing unexpected behavior.

Extend the extraArgs sanitization to also strip -y, --yes, --fgm,
and their values.
This commit is contained in:
SOV710
2026-04-05 03:36:30 +00:00
parent a48d33096a
commit 4056bfa547

View File

@@ -23,7 +23,8 @@ const config = getConfig();
setupProxy(config.OCO_PROXY);
const OCO_FLAGS_WITH_VALUE = new Set(['-c', '--context']);
const OCO_EQUALS_PREFIXES = ['-c=', '--context='];
const OCO_BOOLEAN_FLAGS = new Set(['-y', '--yes', '--fgm']);
const OCO_EQUALS_PREFIXES = ['-c=', '--context=', '-y=', '--yes=', '--fgm='];
const stripOcoFlags = (argv: string[]): string[] => {
const out: string[] = [];
@@ -34,7 +35,11 @@ const stripOcoFlags = (argv: string[]): string[] => {
i++; // skip the value token too
continue;
}
// Equals form: -c=…, --context=…
// Boolean flags: -y, --yes, --fgm
if (OCO_BOOLEAN_FLAGS.has(a)) {
continue;
}
// Equals form: -c=…, --context=…, -y=…, --yes=…, --fgm=…
if (OCO_EQUALS_PREFIXES.some((prefix) => a.startsWith(prefix))) {
continue;
}