From 8c83cf60f9e44cd2893078d2a1ca4b50156e37dc Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Fri, 6 Feb 2026 16:11:18 +0900 Subject: [PATCH] =?UTF-8?q?stageAndCommit=20=E3=81=8B=E3=82=89=20git=20add?= =?UTF-8?q?=20-f=20.takt/reports/=20=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit エージェントが c89ac4c で追加した force-add により、worktree 実行時に .takt/reports/ がコミットに含まれてしまう問題を修正。 .takt/ は .gitignore で除外済みのため force-add は不要。 --- src/__tests__/autoCommit.test.ts | 45 -------------------------------- src/infra/task/git.ts | 12 --------- 2 files changed, 57 deletions(-) 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',