diff --git a/src/__tests__/autoCommit.test.ts b/src/__tests__/autoCommit.test.ts index 40a5300..ad3c42d 100644 --- a/src/__tests__/autoCommit.test.ts +++ b/src/__tests__/autoCommit.test.ts @@ -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'); - }); }); diff --git a/src/infra/task/git.ts b/src/infra/task/git.ts index 778fa9f..add1156 100644 --- a/src/infra/task/git.ts +++ b/src/infra/task/git.ts @@ -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',