You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: improve commit message generation with AI prompts (#596)
- Refactor the commit message generation process to utilize default prompts and enhance clarity while eliminating redundancy.
- Added new properties for subject and summary prompts, while improving cancellation support in async task handling.
- feat: add AI prompts for commit message generation.
- Updated the formatting of the package reference for consistency in the project file.
- Add properties for managing OpenAI subject and summary prompts in the Preference view model.
- Refactor layout and add new input fields for AI subject and summary prompts in the preferences view.
Copy file name to clipboardExpand all lines: src/Commands/GenerateCommitMessage.cs
+38-26Lines changed: 38 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,33 @@ namespace SourceGit.Commands
10
10
/// </summary>
11
11
publicclassGenerateCommitMessage
12
12
{
13
+
privateconststringDEFAULT_SUMMARY_PROMPT="""
14
+
You are an expert developer specialist in creating commits.
15
+
Provide a super concise one sentence overall changes summary of the user `git diff` output following strictly the next rules:
16
+
- Do not use any code snippets, imports, file routes or bullets points.
17
+
- Do not mention the route of file that has been change.
18
+
- Simply describe the MAIN GOAL of the changes.
19
+
- Output directly the summary in plain text.
20
+
""";
21
+
22
+
privateconststringDEFAULT_SUBJECT_PROMPT="""
23
+
You are an expert developer specialist in creating commits messages.
24
+
Your only goal is to retrieve a single commit message.
25
+
Based on the provided user changes, combine them in ONE SINGLE commit message retrieving the global idea, following strictly the next rules:
26
+
- Assign the commit {type} according to the next conditions:
27
+
feat: Only when adding a new feature.
28
+
fix: When fixing a bug.
29
+
docs: When updating documentation.
30
+
style: When changing elements styles or design and/or making changes to the code style (formatting, missing semicolons, etc.) without changing the code logic.
31
+
test: When adding or updating tests.
32
+
chore: When making changes to the build process or auxiliary tools and libraries.
33
+
revert: When undoing a previous commit.
34
+
refactor: When restructuring code without changing its external behavior, or is any of the other refactor types.
35
+
- Do not add any issues numeration, explain your output nor introduce your answer.
36
+
- Output directly only one commit message in plain text with the next format: {type}: {commit_message}.
37
+
- Be as concise as possible, keep the message under 50 characters.
prompt.AppendLine("You are an expert developer specialist in creating commits messages.");
92
-
prompt.AppendLine("Your only goal is to retrieve a single commit message.");
93
-
prompt.AppendLine("Based on the provided user changes, combine them in ONE SINGLE commit message retrieving the global idea, following strictly the next rules:");
94
-
prompt.AppendLine("- Assign the commit {type} according to the next conditions:");
95
-
prompt.AppendLine(" feat: Only when adding a new feature.");
96
-
prompt.AppendLine(" fix: When fixing a bug.");
97
-
prompt.AppendLine(" docs: When updating documentation.");
98
-
prompt.AppendLine(" style: When changing elements styles or design and/or making changes to the code style (formatting, missing semicolons, etc.) without changing the code logic.");
99
-
prompt.AppendLine(" test: When adding or updating tests. ");
100
-
prompt.AppendLine(" chore: When making changes to the build process or auxiliary tools and libraries. ");
101
-
prompt.AppendLine(" revert: When undoing a previous commit.");
102
-
prompt.AppendLine(" refactor: When restructuring code without changing its external behavior, or is any of the other refactor types.");
103
-
prompt.AppendLine("- Do not add any issues numeration, explain your output nor introduce your answer.");
104
-
prompt.AppendLine("- Output directly only one commit message in plain text with the next format: {type}: {commit_message}.");
105
-
prompt.AppendLine("- Be as concise as possible, keep the message under 50 characters.");
106
-
107
-
varrsp=Models.OpenAI.Chat(prompt.ToString(),$"Here are the summaries changes: {summary}",_cancelToken);
<x:Stringx:Key="Text.Preference.AI.SummaryPromptHint"xml:space="preserve">You are an expert developer specialist in creating commits.
409
+
Provide a super concise one sentence overall changes summary of the user `git diff` output following strictly the next rules:
410
+
- Do not use any code snippets, imports, file routes or bullets points.
411
+
- Do not mention the route of file that has been change.
412
+
- Simply describe the MAIN GOAL of the changes.
413
+
- Output directly the summary in plain text.
414
+
</x:String>
415
+
<x:Stringx:Key="Text.Preference.AI.SubjectPromptHint"xml:space="preserve">You are an expert developer specialist in creating commits messages.
416
+
Your only goal is to retrieve a single commit message.
417
+
Based on the provided user changes, combine them in ONE SINGLE commit message retrieving the global idea, following strictly the next rules:
418
+
- Assign the commit {type} according to the next conditions:
419
+
feat: Only when adding a new feature.
420
+
fix: When fixing a bug.
421
+
docs: When updating documentation.
422
+
style: When changing elements styles or design and/or making changes to the code style (formatting, missing semicolons, etc.) without changing the code logic.
423
+
test: When adding or updating tests.
424
+
chore: When making changes to the build process or auxiliary tools and libraries.
425
+
revert: When undoing a previous commit.
426
+
refactor: When restructuring code without changing its external behavior, or is any of the other refactor types.
427
+
- Do not add any issues numeration, explain your output nor introduce your answer.
428
+
- Output directly only one commit message in plain text with the next format: {type}: {commit_message}.
429
+
- Be as concise as possible, keep the message under 50 characters.
0 commit comments