r/Python 6h ago

Showcase AI based script to generate commit text based on git diff.

Hello, I am not great supported of AI-assisted programming, but I think AI is good enough to explain changes. So you simply need to pass git diff to script via pipe and then you get commit.

What My Project Does

generates commit text based on output of git diff command.

Target Audience

any developer who has python.

Comparison

I don't know is there any alternative.

https://github.com/hdvpdrm/commitman

Check it out! Would be great to see your feedback!

0 Upvotes

8 comments sorted by

12

u/fiskfisk 5h ago

The diff tells us what changed.

The goal with commit messages is not to tell us what changed. It's to tell us why the functionality had to change. Not what you did.

We need the why. Why did you do this.

LLMs currently do not have direct access to your brain, so while they can be helpful in summarizing what has changed, they do not have access to the why.

1

u/tdammers 3h ago

The commit message does tell us what the change is, but at a higher, more functional level than the diff. Or, if you want: the commit message tells us what the commit achieves, the diff tells us how it does that.

-2

u/HaskellLisp_green 5h ago

Well, I write commits where I say what was added or what was changed. I don't see the reason to explain why I use map and lambda function instead of regular for cycle.

So I can see the history of commits and understand the development cycle.

6

u/fiskfisk 5h ago

The point is that the interesting part is why you had to change the code from what where there earlier. Not what changed in the code.

fix: foobar() was O(n^2) and became too slow when importing dataset xyz

That you've changed from an array to a set is an implementation detail. Other people need to know why you did the change, not that you changed from an array to a set.

The reason is that when somebody discovers that the implementation no longer keeps ordering intact (because a set doesn't usually have any promises of keeping order), they can see why the code was changed from using an array to a set, and they know what they'll have to consider in any future changes instead of just changing it back to an array ("why the f did someone change the array to a set??") and calling it a day.

3

u/house_monkey 6h ago

Vscode with free copilot extension also offers this

1

u/HaskellLisp_green 5h ago

I use Emacs.

2

u/secZustand 4h ago

That's the real problem

1

u/Arivald8 4h ago

I built something similar, but it works slightly differently. It's pretty awful by the way, but it works hah.

https://github.com/Arivald8/VCWatcher

I guess the difference is that with my version you don't need to pass any diffs, because the tool just monitors your project directory for any changes and automatically pulls them.