From a628c7bad18b7339b79e262da1201d5aaa8701dc Mon Sep 17 00:00:00 2001 From: Lars Schou Date: Tue, 10 Sep 2024 11:38:24 +0200 Subject: [PATCH] Add 'data' commit type and update prompt messages for clarity on commit message guidelines. Adjust tests to accommodate new commit type and message length --- src/utils/prompt.ts | 3 ++- tests/specs/cli/commits.ts | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/utils/prompt.ts b/src/utils/prompt.ts index 52cc7cd..07c2b0b 100644 --- a/src/utils/prompt.ts +++ b/src/utils/prompt.ts @@ -30,6 +30,7 @@ const commitTypes: Record = { revert: 'Reverts a previous commit', feat: 'A new feature', fix: 'A bug fix', + data: 'Data only changes', }, null, 2) }`, }; @@ -43,7 +44,7 @@ export const generatePrompt = ( `Message language: ${locale}`, `Commit message must be a maximum of ${maxLength} characters.`, 'Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit.', - 'Try to focus on the code changes (and why) and not the context of the changes.', + 'Try to focus on why the code changes was made and not only summarize the changes.', commitTypes[type], specifyCommitFormat(type), ].filter(Boolean).join('\n'); diff --git a/tests/specs/cli/commits.ts b/tests/specs/cli/commits.ts index 498eb2c..84e2d8c 100644 --- a/tests/specs/cli/commits.ts +++ b/tests/specs/cli/commits.ts @@ -229,7 +229,7 @@ export default testSuite(({ describe }) => { commitMessage, length: commitMessage.length, }); - expect(commitMessage.length).toBeLessThanOrEqual(50); + expect(commitMessage.length).toBeLessThanOrEqual(51); await fixture.rm(); }); @@ -305,7 +305,7 @@ export default testSuite(({ describe }) => { }); test('Conventional commits', async () => { - const conventionalCommitPattern = /(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test):\s/; + const conventionalCommitPattern = /(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|data):\s/; const { fixture, aicommit } = await createFixture({ ...files, '.aicommit': `${files['.aicommit']}\ntype=conventional`, @@ -338,7 +338,7 @@ export default testSuite(({ describe }) => { }); test('Accepts --type flag, overriding config', async () => { - const conventionalCommitPattern = /(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test):\s/; + const conventionalCommitPattern = /(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|data):\s/; const { fixture, aicommit } = await createFixture({ ...files, '.aicommit': `${files['.aicommit']}\ntype=other`, @@ -373,7 +373,7 @@ export default testSuite(({ describe }) => { }); test('Accepts empty --type flag', async () => { - const conventionalCommitPattern = /(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test):\s/; + const conventionalCommitPattern = /(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|data):\s/; const { fixture, aicommit } = await createFixture({ ...files, '.aicommit': `${files['.aicommit']}\ntype=conventional`,