Skip to content

Commit b8d3750

Browse files
committed
Remove duplicate prompts from commit message generation output
- make sure no duplicated (after simplfying) prompt are placed in commit message
1 parent 4416b26 commit b8d3750

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎apps/editor/src/commands/generate-commit-message-command/generate-commit-message-command.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,14 @@ export const generate_commit_message_command = (
238238
const selected_prompts_text =
239239
include_prompts_setting && selected_prompts.length > 0
240240
? '\n\n' +
241-
selected_prompts
242-
.map(
243-
(p) => `- ${simplify_prompt_symbols({ prompt: p.prompt })}`
241+
[
242+
...new Set(
243+
selected_prompts.map((p) =>
244+
simplify_prompt_symbols({ prompt: p.prompt })
245+
)
244246
)
247+
]
248+
.map((s) => `- ${s}`)
245249
.join('\n')
246250
: ''
247251

@@ -260,10 +264,14 @@ export const generate_commit_message_command = (
260264
const prompts_text =
261265
include_prompts_setting && relevant_prompts.length > 0
262266
? '\n\n' +
263-
relevant_prompts
264-
.map(
265-
(p) => `- ${simplify_prompt_symbols({ prompt: p.prompt })}`
267+
[
268+
...new Set(
269+
relevant_prompts.map((p) =>
270+
simplify_prompt_symbols({ prompt: p.prompt })
271+
)
266272
)
273+
]
274+
.map((s) => `- ${s}`)
267275
.join('\n')
268276
: ''
269277
repository.inputBox.value = commit_message + prompts_text

0 commit comments

Comments
 (0)