Skip to content

feat: Add commit_template option #1742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lua/neogit/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ end
---@field mappings? NeogitConfigMappings
---@field notification_icon? string
---@field use_default_keymaps? boolean
---@field commit_template? string
---@field highlight? HighlightOptions
---@field builders? { [string]: fun(builder: PopupBuilder) }

Expand Down Expand Up @@ -446,6 +447,7 @@ function M.get_default_values()
["?"] = "",
},
},
commit_template = "",
commit_editor = {
kind = "tab",
show_staged_diff = true,
Expand Down
11 changes: 11 additions & 0 deletions lua/neogit/popups/commit/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local input = require("neogit.lib.input")
local notification = require("neogit.lib.notification")
local config = require("neogit.config")
local a = require("plenary.async")
local path = require("plenary.path")

---@param popup PopupData
---@return boolean
Expand All @@ -33,6 +34,16 @@ local function confirm_modifications()
end

local function do_commit(popup, cmd)
local template_path = config.values.commit_template
if template_path ~= "" then
local template_file = path:new(template_path)
if template_file:exists() then
cmd = cmd.args("--template=" .. template_file:absolute())
else
notification.warn("Commit template file does not exist: \n" .. template_path)
end
end

client.wrap(cmd.arg_list(popup:get_arguments()), {
autocmd = "NeogitCommitComplete",
msg = {
Expand Down