Skip to content

Commit 0239d5b

Browse files
committed
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.
1 parent b4aac53 commit 0239d5b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/cli.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const config = getConfig();
2323
setupProxy(config.OCO_PROXY);
2424

2525
const OCO_FLAGS_WITH_VALUE = new Set(['-c', '--context']);
26-
const OCO_EQUALS_PREFIXES = ['-c=', '--context='];
26+
const OCO_BOOLEAN_FLAGS = new Set(['-y', '--yes', '--fgm']);
27+
const OCO_EQUALS_PREFIXES = ['-c=', '--context=', '-y=', '--yes=', '--fgm='];
2728

2829
const stripOcoFlags = (argv: string[]): string[] => {
2930
const out: string[] = [];
@@ -34,7 +35,11 @@ const stripOcoFlags = (argv: string[]): string[] => {
3435
i++; // skip the value token too
3536
continue;
3637
}
37-
// Equals form: -c=…, --context=…
38+
// Boolean flags: -y, --yes, --fgm
39+
if (OCO_BOOLEAN_FLAGS.has(a)) {
40+
continue;
41+
}
42+
// Equals form: -c=…, --context=…, -y=…, --yes=…, --fgm=…
3843
if (OCO_EQUALS_PREFIXES.some((prefix) => a.startsWith(prefix))) {
3944
continue;
4045
}

0 commit comments

Comments
 (0)