From a48d33096af65c3ab32a53293c5c5efec3196da9 Mon Sep 17 00:00:00 2001 From: SOV710 Date: Sun, 5 Apr 2026 03:36:11 +0000 Subject: [PATCH] fix(cli): strip -c/--context from extraArgs to prevent git commit conflict cleye's ignoreArgv passes unconsumed flags and arguments through to the internal `git commit` execa call. Although -c/--context is defined as a known cleye flag, a defensive guard is needed to strip it from extraArgs in case it leaks through, which would conflict with git's own handling. Add a sanitization step at the entry of commit() that filters -c, --context, and their values from extraArgs before they are forwarded to the git commit invocation. --- src/cli.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index f83f3ad..b01ea00 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -22,7 +22,29 @@ import { runMigrations } from './migrations/_run.js'; const config = getConfig(); setupProxy(config.OCO_PROXY); -const extraArgs = process.argv.slice(2); +const OCO_FLAGS_WITH_VALUE = new Set(['-c', '--context']); +const OCO_EQUALS_PREFIXES = ['-c=', '--context=']; + +const stripOcoFlags = (argv: string[]): string[] => { + const out: string[] = []; + for (let i = 0; i < argv.length; i++) { + const a = argv[i]; + // String flags with a separate value token: -c , --context + if (OCO_FLAGS_WITH_VALUE.has(a)) { + i++; // skip the value token too + continue; + } + // Equals form: -c=…, --context=… + if (OCO_EQUALS_PREFIXES.some((prefix) => a.startsWith(prefix))) { + continue; + } + out.push(a); + } + return out; +}; + +const rawArgv = process.argv.slice(2); +const extraArgs = stripOcoFlags(rawArgv); cli( { @@ -82,5 +104,5 @@ cli( commit(extraArgs, flags.context, false, flags.fgm, flags.yes); }, - extraArgs + rawArgv );