Skip to content

Commit b95cf5b

Browse files
committed
feat(git): support multiple log output formats
- map format argument to valid git log options - update schema description to list all supported formats - improve flexibility for log output customization
1 parent 854faff commit b95cf5b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lua/codecompanion/_extensions/gitcommit/tools/git.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,18 @@ function GitTool.get_log(count, format)
181181
count = count or 10
182182
format = format or "oneline"
183183

184-
local cmd = string.format("git log -%d --%s", count, format)
184+
-- Map format to valid git log options
185+
local format_map = {
186+
oneline = "--oneline",
187+
short = "--pretty=short",
188+
medium = "--pretty=medium",
189+
full = "--pretty=full",
190+
fuller = "--pretty=fuller",
191+
format = "--pretty=format"
192+
}
193+
194+
local format_option = format_map[format] or "--oneline"
195+
local cmd = string.format("git log -%d %s", count, format_option)
185196
return execute_git_command(cmd)
186197
end
187198

lua/codecompanion/_extensions/gitcommit/tools/git_read.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ GitRead.schema = {
4444
},
4545
format = {
4646
type = "string",
47-
description = "Format for log output (oneline, short, full, etc.)",
47+
description = "Format for log output (oneline, short, medium, full, fuller)",
4848
},
4949
staged = {
5050
type = "boolean",

0 commit comments

Comments
 (0)