mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Detect git commit anywhere in command, not just at start
This commit is contained in:
@@ -768,6 +768,69 @@ describe('ShellTool', () => {
|
|||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add co-author when git commit is prefixed with cd command', async () => {
|
||||||
|
const command = 'cd /tmp/test && git commit -m "Test commit"';
|
||||||
|
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 <qwen-coder@alibabacloud.com>',
|
||||||
|
),
|
||||||
|
expect.any(String),
|
||||||
|
expect.any(Function),
|
||||||
|
mockAbortSignal,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add co-author to git commit with multi-line message', async () => {
|
||||||
|
const command = `git commit -m "Fix bug
|
||||||
|
|
||||||
|
This is a detailed description
|
||||||
|
spanning multiple lines"`;
|
||||||
|
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 <qwen-coder@alibabacloud.com>',
|
||||||
|
),
|
||||||
|
expect.any(String),
|
||||||
|
expect.any(Function),
|
||||||
|
mockAbortSignal,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -338,9 +338,9 @@ export class ShellToolInvocation extends BaseToolInvocation<
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this is a git commit command
|
// Check if this is a git commit command (anywhere in the command, e.g., after "cd /path &&")
|
||||||
const gitCommitPattern = /^git\s+commit/;
|
const gitCommitPattern = /\bgit\s+commit\b/;
|
||||||
if (!gitCommitPattern.test(command.trim())) {
|
if (!gitCommitPattern.test(command)) {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user