From 5bd1822b7d740da689695ab0fe22f7a8eac558b4 Mon Sep 17 00:00:00 2001 From: Alexander Farber Date: Mon, 15 Dec 2025 11:00:21 +0100 Subject: [PATCH] Fix gitCoAuthor not added for combined flags like -am --- packages/core/src/tools/shell.test.ts | 30 +++++++++++++++++++++++++++ packages/core/src/tools/shell.ts | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/core/src/tools/shell.test.ts b/packages/core/src/tools/shell.test.ts index 3760266a..0b34b8c1 100644 --- a/packages/core/src/tools/shell.test.ts +++ b/packages/core/src/tools/shell.test.ts @@ -608,6 +608,36 @@ describe('ShellTool', () => { ); }); + it('should handle git commit with combined short flags like -am', async () => { + const command = 'git commit -am "Add feature"'; + const invocation = shellTool.build({ command, is_background: false }); + const promise = invocation.execute(mockAbortSignal); + + resolveExecutionPromise({ + rawOutput: Buffer.from(''), + output: '', + exitCode: 0, + signal: null, + error: null, + aborted: false, + pid: 12345, + executionMethod: 'child_process', + }); + + await promise; + + expect(mockShellExecutionService).toHaveBeenCalledWith( + expect.stringContaining( + 'Co-authored-by: Qwen-Coder ', + ), + expect.any(String), + expect.any(Function), + mockAbortSignal, + false, + {}, + ); + }); + it('should not modify non-git commands', async () => { const command = 'npm install'; const invocation = shellTool.build({ command, is_background: false }); diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts index 6e92954e..077bc693 100644 --- a/packages/core/src/tools/shell.ts +++ b/packages/core/src/tools/shell.ts @@ -350,8 +350,8 @@ export class ShellToolInvocation extends BaseToolInvocation< Co-authored-by: ${gitCoAuthorSettings.name} <${gitCoAuthorSettings.email}>`; // Handle different git commit patterns - // Match -m "message" or -m 'message' - const messagePattern = /(-m\s+)(['"])((?:\\.|[^\\])*?)(\2)/; + // Match -m "message" or -m 'message', including combined flags like -am + const messagePattern = /(-[a-zA-Z]*m\s+)(['"])((?:\\.|[^\\])*?)(\2)/; const match = command.match(messagePattern); if (match) {