Skip to content

Commit 11d3aae

Browse files
committed
Merge duplicate commit prompts
- identical prompts should not get attached to commit messages
1 parent 69b5c92 commit 11d3aae

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎apps/editor/src/utils/prompts-for-commit-messages-utils.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,20 @@ export namespace PromptsForCommitMessagesUtils {
7474
all_prompts[params.workspace_root] = []
7575
}
7676

77-
const new_prompt: Prompt = {
78-
files: params.files,
79-
prompt: params.prompt
77+
const existing = all_prompts[params.workspace_root].find(
78+
(p) => p.prompt == params.prompt
79+
)
80+
81+
if (existing) {
82+
existing.files = Array.from(new Set([...existing.files, ...params.files]))
83+
} else {
84+
const new_prompt: Prompt = {
85+
files: params.files,
86+
prompt: params.prompt
87+
}
88+
all_prompts[params.workspace_root].push(new_prompt)
8089
}
8190

82-
all_prompts[params.workspace_root].push(new_prompt)
8391
save_all({
8492
extension_context: params.extension_context,
8593
prompts: all_prompts

0 commit comments

Comments
 (0)