feat(git): Add configuration option for 'Generated-by' line in commit messages (#2708)

This commit is contained in:
Eldad Zack
2025-09-15 07:16:35 +02:00
committed by GitHub
parent 56951378f1
commit 846736789e
2 changed files with 8 additions and 0 deletions

View File

@@ -491,6 +491,7 @@ M._defaults = {
auto_approve_tool_permissions = true, -- Default: show permission prompts for all tools
auto_check_diagnostics = true,
enable_fastapply = false,
include_generated_by_commit_line = false, -- Controls if 'Generated-by: <provider/model>' line is added to git commit message
},
prompt_logger = { -- logs prompts to disk (timestamped, for replay/debugging)
enabled = true, -- toggle logging entirely

View File

@@ -462,6 +462,13 @@ function M.git_commit(input, opts)
commit_msg_lines[#commit_msg_lines + 1] = line:gsub('"', '\\"')
end
commit_msg_lines[#commit_msg_lines + 1] = ""
-- add Generated-by line using provider and model name
if Config.behaviour and Config.behaviour.include_generated_by_commit_line then
local provider_name = Config.provider or "unknown"
local model_name = (Config.providers and Config.providers[provider_name] and Config.providers[provider_name].model)
or "unknown"
commit_msg_lines[#commit_msg_lines + 1] = string.format("Generated-by: %s/%s", provider_name, model_name)
end
if git_user ~= "" and git_email ~= "" then
commit_msg_lines[#commit_msg_lines + 1] = string.format("Signed-off-by: %s <%s>", git_user, git_email)
end