Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/generateCommitMessageFromGitDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ export const generateCommitMessageByDiff = async (

const commitMessages = await Promise.all(commitMessagePromises);

// When OCO_ONE_LINE_COMMIT is enabled, combine the first line of each
// split-diff message into a single line instead of joining with '\n\n'.
if (config.OCO_ONE_LINE_COMMIT) {
return commitMessages
.filter(Boolean)
.map((msg) => msg!.split('\n')[0].trim())
.join('; ');
}

return commitMessages.join('\n\n');
}

Expand Down
12 changes: 11 additions & 1 deletion src/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,17 @@ export const getMainCommitPrompt = async (
}

// Replace example prompt with a prompt that's generated by OpenAI for the commitlint config.
const commitLintConfig = await utils.getCommitlintLLMConfig();
let commitLintConfig = await utils.getCommitlintLLMConfig();

// Guard against outdated or corrupted config files that are missing the
// prompts field (e.g. generated by an older version of opencommit).
if (!Array.isArray(commitLintConfig.prompts)) {
note(
'Commitlint LLM config is missing prompts, regenerating...'
);
await configureCommitlintIntegration(true);
commitLintConfig = await utils.getCommitlintLLMConfig();
}

return [
commitlintPrompts.INIT_MAIN_PROMPT(
Expand Down
Loading