mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-04-20 03:02:51 -04:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user