-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Git Commit Code Action with Commit Message Guidelines
This commit adds a new code action for creating Git commit messages that follow best practices. The code action provides a template with clear guidelines for the commit message structure, including the subject line and body.
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
local prompt = [[ | ||
Please take the following unstructured draft text, which may contain typos and unclear phrasing, | ||
and transform it into a clear, concise, and well-structured Git commit message according | ||
to the following rules: | ||
1. Separate subject from body with a blank line | ||
2. Limit the subject line to 50 characters | ||
3. Capitalize the subject line | ||
4. Do not end the subject line with a period | ||
5. Use the imperative mood in the subject line | ||
6. Wrap the body at 72 characters | ||
7. Use the body to explain what and why vs. how | ||
--- | ||
]] | ||
|
||
local M = { | ||
is_triggered = function(selection_range) | ||
return true | ||
end, | ||
|
||
action_name = function() | ||
return "Improve Git Message" | ||
end, | ||
|
||
process_answer = function(text, selection_range) | ||
return text | ||
end, | ||
|
||
create_prompt = function(selection_range) | ||
local git_draft_message = active_doc:text_from_range(active_doc:root():range()) | ||
return table.concat({ | ||
[[ Human: | ||
]], prompt, [[ | ||
Here is the unstructured draft text: | ||
<task> | ||
]], git_draft_message, [[</task> | ||
Assistant: ]] }) | ||
end, | ||
|
||
placement_range = function(selection_range) | ||
return active_doc:root():range() | ||
end | ||
} | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters