Skip to content

Commit

Permalink
refactor: improve commit length enforcement (Nutlope#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored May 3, 2023
1 parent f53fb85 commit f466f05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/utils/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ const getPrompt = (
diff: string,
maxLength: number,
) => `${[
'Generate a concise git commit message written in present tense for the following code diff with the given specifications.',
'Generate a concise git commit message written in present tense for the following code diff with the given specifications below:',
`Message language: ${locale}`,
`Max message character length: ${maxLength}`,
'Exclude anything unnecessary such as the original translation—your entire response will be passed directly into git commit.',
`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.',
].join('\n')}\n\n${diff}`;

const generateStringFromLength = (length: number) => {
Expand Down
12 changes: 6 additions & 6 deletions tests/specs/cli/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default testSuite(({ describe }) => {
commitMessage,
length: commitMessage.length,
});
expect(commitMessage.length <= 50).toBe(true);
expect(commitMessage.length).toBeLessThanOrEqual(50);

await fixture.rm();
});
Expand Down Expand Up @@ -122,7 +122,7 @@ export default testSuite(({ describe }) => {
commitMessage,
length: commitMessage.length,
});
expect(commitMessage.length <= 50).toBe(true);
expect(commitMessage.length).toBeLessThanOrEqual(50);

await fixture.rm();
});
Expand Down Expand Up @@ -165,7 +165,7 @@ export default testSuite(({ describe }) => {
commitMessage,
length: commitMessage.length,
});
expect(commitMessage.length <= 50).toBe(true);
expect(commitMessage.length).toBeLessThanOrEqual(50);

await fixture.rm();
});
Expand Down Expand Up @@ -203,7 +203,7 @@ export default testSuite(({ describe }) => {
length: commitMessage.length,
});
expect(commitMessage).toMatch(japanesePattern);
expect(commitMessage.length <= 50).toBe(true);
expect(commitMessage.length).toBeLessThanOrEqual(50);

await fixture.rm();
});
Expand Down Expand Up @@ -267,7 +267,7 @@ export default testSuite(({ describe }) => {
commitMessage,
length: commitMessage.length,
});
expect(commitMessage.length <= 50).toBe(true);
expect(commitMessage.length).toBeLessThanOrEqual(50);

await fixture.rm();
});
Expand Down Expand Up @@ -302,7 +302,7 @@ export default testSuite(({ describe }) => {
commitMessage,
length: commitMessage.length,
});
expect(commitMessage.length <= 50).toBe(true);
expect(commitMessage.length).toBeLessThanOrEqual(50);

await fixture.rm();
});
Expand Down

0 comments on commit f466f05

Please sign in to comment.