Skip to content

Commit

Permalink
Add 'data' commit type and update prompt messages for clarity on comm…
Browse files Browse the repository at this point in the history
…it message guidelines. Adjust tests to accommodate new commit type and message length
  • Loading branch information
negoziator committed Sep 10, 2024
1 parent 180a4ff commit a628c7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/utils/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const commitTypes: Record<CommitType, string> = {
revert: 'Reverts a previous commit',
feat: 'A new feature',
fix: 'A bug fix',
data: 'Data only changes',
}, null, 2)
}`,
};
Expand All @@ -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');
8 changes: 4 additions & 4 deletions tests/specs/cli/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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`,
Expand Down Expand Up @@ -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`,
Expand Down Expand Up @@ -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`,
Expand Down

0 comments on commit a628c7b

Please sign in to comment.