From 9a841d946fd4d0fc6a56b64728ca8425a7c3990a Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 3 May 2023 22:37:42 +0900 Subject: [PATCH] fix: --all flag to only stage tracked files --- src/commands/aicommits.ts | 3 ++- tests/specs/cli/commits.ts | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/commands/aicommits.ts b/src/commands/aicommits.ts index 91b7092..2c6cb2b 100644 --- a/src/commands/aicommits.ts +++ b/src/commands/aicommits.ts @@ -27,7 +27,8 @@ export default async ( const detectingFiles = spinner(); if (stageAll) { - await execa('git', ['add', '--all']); + // This should be equivalent behavior to `git commit --all` + await execa('git', ['add', '--update']); } detectingFiles.start('Detecting staged files'); diff --git a/tests/specs/cli/commits.ts b/tests/specs/cli/commits.ts index 497acf6..f88916a 100644 --- a/tests/specs/cli/commits.ts +++ b/tests/specs/cli/commits.ts @@ -98,10 +98,11 @@ export default testSuite(({ describe }) => { await git('add', ['data.json']); await git('commit', ['-m', 'wip']); + // Change tracked file await fixture.writeFile('data.json', 'Test'); - const statusBefore = await git('status', ['--short', '--untracked-files=no']); - expect(statusBefore.stdout).toBe(' M data.json'); + const statusBefore = await git('status', ['--short']); + expect(statusBefore.stdout).toBe(' M data.json\n?? .aicommits'); const committing = aicommits(['--all']); committing.stdout!.on('data', (buffer: Buffer) => { @@ -114,8 +115,8 @@ export default testSuite(({ describe }) => { await committing; - const statusAfter = await git('status', ['--short', '--untracked-files=no']); - expect(statusAfter.stdout).toBe(''); + const statusAfter = await git('status', ['--short']); + expect(statusAfter.stdout).toBe('?? .aicommits'); const { stdout: commitMessage } = await git('log', ['-n1', '--pretty=format:%s']); console.log({