-
Notifications
You must be signed in to change notification settings - Fork 104
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
Please help to get git diff
into prompt :)
#101
Comments
Hi @dvogt23 , Thanks! You can also modify the prompt templates programmatically and I would do it like that: Create a lua function to
Would that work for you? |
Seems strange, did try it like this: function get_git_diff()
-- Define the command to get the git diff
local command = "git diff"
-- Use io.popen to run the command and capture its output
local handle = io.popen(command)
local result = handle:read("*a") -- Read all output
handle:close()
return result
end
require("gen").prompts["Commit summary"] = {
prompt = "You are an expert developer specialist in creating commits. Provide a super concise one sentence overall changes summary of the user "
.. get_git_diff()
.. " output following strictly the next rules: - Do not use any code snippets, imports, file routes or bullets points. - Do not mention the route of file that has been change. - Simply describe the MAIN GOAL of the changes. - Output directly the summary in plain text.",
replace = true,
} but getting always like this as output: I think I have to chain the output of the first prompt, to this:
Is this possible somehow? 😆 |
Just wanted to share my solution to this problem if you are still struggling with this. It's missing error handling but should work most of the time. {
'David-Kunz/gen.nvim/issues/101',
opts = { display_mode = 'split' },
config = function(_, opts)
local gen = require('gen')
gen.setup(opts)
gen.prompts['Commit'] = {
prompt = function()
local diff = vim.system({ 'git', 'diff', '--staged' }, { text = true }):wait()
return [[
...prompt...
Git diff: ]] .. diff.stdout
end,
replace = true,
extract = '```$filetype\n(.-)```',
}
end
} |
Great, thanks @Rasmus-Bertell now Im able to get the summary. I have to chain the output of summary promt to another one for getting a commit message. Do you have an idea? |
No, sorry. This covers my needs so I'm not motivated to explore it further. |
Hi @dvogt23 , I'm afraid follow-up prompts are not yet possible. Only manually with I'll chink about supporting prompt chains. |
For now, would it be possible to put everything in one prompt? |
The problem is that many models have a hard time generating proper commit messages from just the diff, or at least that's what I have noticed, especially if the diff is long. So I think the solution is to first generate a short summary of changes with one prompt and pipe it to another one that makes the actual commit message. |
Hey thanks for this great plugin, I would try to have something like this as a prompt for my commit messages, but have no idea how to get my local
git diff
into this prompt. Any suggestions? :)The text was updated successfully, but these errors were encountered: