aider icon indicating copy to clipboard operation
aider copied to clipboard

No need for the diff itself in commit msgs

Open nitsanavni opened this issue 2 years ago • 3 comments

Very cool project! Inspiring. Going through commits on this repo I find duplication as some commit msgs contain the conversation with GPT including the diff, while the commit object itself is the diff. WDYT?

nitsanavni avatar Jul 05 '23 07:07 nitsanavni

I was thinking the same, but it's still nice to have the full conversation with the diffs in the commit messages when testing the tool.

For real production use, there would need to be a real commit message template that adheres to a standard, for example https://www.conventionalcommits.org/en/v1.0.0/.

I'm working on an agent that takes care of building good commits and writing useful commit messages, but there are many other projects that do that, such as https://github.com/markuswt/gpt-commit/blob/main/gpt-commit.py

j4yh3m avatar Jul 05 '23 09:07 j4yh3m

BTW the commit message itself isn't maybe exactly the diff that is shown (not sure about that), it could differ if formatting and indentation.

Actually I'm wondering what it does about formatting, probably it just makes up some formatting when starting with a blank repo and then does similar formatting to the sample files provided.

It would probably be a good idea to have a way to define a formatter in the aider config, so it could reformat the code before committing.

j4yh3m avatar Jul 05 '23 09:07 j4yh3m

Thanks for trying aider and making these suggestions!

The headline of the commit message is generated by gpt-3.5 as a sensible summary of the changes. You can see the prompt here:

https://github.com/paul-gauthier/aider/blob/fb5af6ec8bb70b2ca4d633d6ec890b94c505d9c0/aider/prompts.py#L5

The remaining body of the commit message just serves as a record of the chat conversation which resulted in the commit, code blocks and all.

The code blocks generated by GPT are not exactly the same as the diffs which are applied to the files. Because GPT is often sloppy/imprecise in its code editing, aider has to take liberties and use "best efforts" to apply the suggested edit to the files.

So there is some value in having a record of "what GPT said to do" in addition to the actual git diffs.

paul-gauthier avatar Jul 07 '23 17:07 paul-gauthier

Thanks for clarifying! I suggest keeping a record of conversations under .aider/conversations-record/ - it will be tracked by git by default, however the user may opt out by .gitignoreing it. Thus we conform to the usual use of git commit messages - tracking intentions, change summaries and similar.

If .aider/conversations-record/ is commited together with the relevant changes, then you can see a similar git log like this:

git log --patch

or

git log -p

nitsanavni avatar Jul 14 '23 06:07 nitsanavni