Skip to content

Commit 7b76458

Browse files
author
prod-broke-again
committed
feat: Улучшить парсинг сгенерированных сообщений коммитов 💡
- 💡 Избежать дублирования префиксов типов коммитов (например, `feat:`) при парсинге ответов ИИ. - 🧹 Удалить существующий префикс типа коммита из тела сообщения, если он уже присутствует в ответе ИИ. - ⚙️ Оптимизировать процесс извлечения основной части сообщения коммита в полном режиме.
1 parent 3399ee8 commit 7b76458

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/application/services/CommitGenerator.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,16 @@ Description:`;
364364
cleaned = cleaned.replace(/^["'`]|["'`]$/g, '');
365365

366366
// For full mode: if the response contains "feat:", "fix:", etc. but has text before it, extract from that point
367+
// But remove the commit type prefix since it will be added by CommitMessage.create()
367368
if (isFullMode) {
368369
const commitTypeMatch = cleaned.match(/(?:^|\n)((?:feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(?:\([^)]+\))?:.*)/i);
369-
if (commitTypeMatch && commitTypeMatch.index && commitTypeMatch.index > 0) {
370-
cleaned = cleaned.substring(commitTypeMatch.index).trim();
370+
if (commitTypeMatch && commitTypeMatch.index !== undefined) {
371+
if (commitTypeMatch.index > 0) {
372+
// Extract from commit type if there's text before it
373+
cleaned = cleaned.substring(commitTypeMatch.index).trim();
374+
}
375+
// Remove the commit type prefix (feat:, fix:, etc.) since it will be added by CommitMessage.create()
376+
cleaned = cleaned.replace(/^(?:feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(?:\([^)]+\))?:\s*/i, '');
371377
}
372378
} else {
373379
// For lite mode: remove commit type prefix if present (feat:, fix:, etc.)

0 commit comments

Comments
 (0)