Skip to content

Commit 3472947

Browse files
committed
refactor(gitcommit): Replace chat:add_reference with chat:add_context
- Optimize context processing related to Slash commands - Fix context references during error handling
1 parent 6f27c87 commit 3472947

File tree

1 file changed

+5
-5
lines changed
  • lua/codecompanion/_extensions/gitcommit

1 file changed

+5
-5
lines changed

lua/codecompanion/_extensions/gitcommit/init.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ local function setup_slash_commands(opts)
161161
stdout:close()
162162
stderr:close()
163163
if code == 0 then
164-
chat:add_reference({
164+
chat:add_context({
165165
role = "user",
166166
content = string.format("Selected commit (%s) full content:\n```\n%s\n```", choice.hash, output),
167167
}, "git", "<git_commit>")
168168
else
169-
chat:add_reference(
169+
chat:add_context(
170170
{ role = "user", content = "Error: Failed to get commit content.\n" .. error_output },
171171
"git",
172172
"<git_error>"
@@ -230,11 +230,11 @@ local function setup_slash_commands(opts)
230230
end
231231
end
232232
if #items == 0 then
233-
return chat:add_reference({ role = "user", content = "No commits found." }, "git", "<git_error>")
233+
return chat:add_context({ role = "user", content = "No commits found." }, "git", "<git_error>")
234234
end
235235
select_commit(chat, items)
236236
else
237-
chat:add_reference(
237+
chat:add_context(
238238
{ role = "user", content = "Error: Failed to get git log\n" .. error_output },
239239
"git",
240240
"<git_error>"
@@ -266,7 +266,7 @@ local function setup_slash_commands(opts)
266266
description = "Select a commit and insert its full content (message + diff)",
267267
callback = function(chat)
268268
if not Git.is_repository() then
269-
return chat:add_reference({ role = "user", content = "Error: Not in a git repository" }, "git", "<git_error>")
269+
return chat:add_context({ role = "user", content = "Error: Not in a git repository" }, "git", "<git_error>")
270270
end
271271
get_commit_list(chat, opts)
272272
end,

0 commit comments

Comments
 (0)