stageAndCommit から git add -f .takt/reports/ を削除
エージェントが c89ac4c で追加した force-add により、worktree 実行時に .takt/reports/ がコミットに含まれてしまう問題を修正。 .takt/ は .gitignore で除外済みのため force-add は不要。
This commit is contained in:
parent
00174ee4a7
commit
8c83cf60f9
@ -153,49 +153,4 @@ describe('autoCommitAndPush', () => {
|
||||
expect((commitCall![1] as string[])[2]).toBe('takt: 認証機能を追加する');
|
||||
});
|
||||
|
||||
it('should force-add .takt/reports/ to include gitignored reports', () => {
|
||||
mockExecFileSync.mockImplementation((cmd, args) => {
|
||||
const argsArr = args as string[];
|
||||
if (argsArr[0] === 'status') {
|
||||
return 'M src/index.ts\n';
|
||||
}
|
||||
if (argsArr[0] === 'rev-parse') {
|
||||
return 'abc1234\n';
|
||||
}
|
||||
return Buffer.from('');
|
||||
});
|
||||
|
||||
autoCommitAndPush('/tmp/clone', 'my-task', '/project');
|
||||
|
||||
// Verify git add -f .takt/reports/ was called
|
||||
expect(mockExecFileSync).toHaveBeenCalledWith(
|
||||
'git',
|
||||
['add', '-f', '.takt/reports/'],
|
||||
expect.objectContaining({ cwd: '/tmp/clone' })
|
||||
);
|
||||
});
|
||||
|
||||
it('should continue even if .takt/reports/ does not exist', () => {
|
||||
let forceAddCalled = false;
|
||||
mockExecFileSync.mockImplementation((cmd, args) => {
|
||||
const argsArr = args as string[];
|
||||
if (argsArr[0] === 'add' && argsArr[1] === '-f') {
|
||||
forceAddCalled = true;
|
||||
throw new Error('pathspec .takt/reports/ did not match any files');
|
||||
}
|
||||
if (argsArr[0] === 'status') {
|
||||
return 'M src/index.ts\n';
|
||||
}
|
||||
if (argsArr[0] === 'rev-parse') {
|
||||
return 'abc1234\n';
|
||||
}
|
||||
return Buffer.from('');
|
||||
});
|
||||
|
||||
const result = autoCommitAndPush('/tmp/clone', 'my-task', '/project');
|
||||
|
||||
expect(forceAddCalled).toBe(true);
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.commitHash).toBe('abc1234');
|
||||
});
|
||||
});
|
||||
|
||||
@ -7,22 +7,10 @@ import { execFileSync } from 'node:child_process';
|
||||
/**
|
||||
* Stage all changes and create a commit.
|
||||
* Returns the short commit hash if changes were committed, undefined if no changes.
|
||||
*
|
||||
* Note: .takt/reports/ is force-added because .takt/ is gitignored.
|
||||
* When using worktree mode, reports are generated inside the clone's .takt/reports/
|
||||
* and must be included in the commit.
|
||||
*/
|
||||
export function stageAndCommit(cwd: string, message: string): string | undefined {
|
||||
execFileSync('git', ['add', '-A'], { cwd, stdio: 'pipe' });
|
||||
|
||||
// Force-add .takt/reports/ even though .takt/ is gitignored.
|
||||
// This ensures worktree-generated reports are included in the commit.
|
||||
try {
|
||||
execFileSync('git', ['add', '-f', '.takt/reports/'], { cwd, stdio: 'pipe' });
|
||||
} catch {
|
||||
// Ignore errors if .takt/reports/ doesn't exist
|
||||
}
|
||||
|
||||
const statusOutput = execFileSync('git', ['status', '--porcelain'], {
|
||||
cwd,
|
||||
stdio: 'pipe',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user