Nutlope / aicommits

A CLI that writes your git commit messages for you with AI
https://www.npmjs.com/package/aicommits
MIT License
7.53k stars 360 forks source link

Take into account previous commit messages #238

Open DanielWeidensdoerfer opened 11 months ago

DanielWeidensdoerfer commented 11 months ago

Feature request

Option to take preivous commit messages into account when creating a new one.

Why?

So that the generated commit messages are in same style as previous ones. Therefore increasing the chance of suggested message to fit.

Alternatives

Reject the suggested commit msg and manually commit.

Additional context

No response

joeytwiddle commented 10 months ago

I had the exact same idea, and implemented it here:

https://github.com/joeytwiddle/aicommits/commit/890996fa55c82809615047a07c345eac9bcece53

Feel free to grab that code. Or I can open a pull request if you prefer.

Concerns:

  1. Perhaps it should be an option in the config file, so people can enable or disable it. (It certainly makes the prompt larger.)
moritztim commented 10 months ago

I think there is one thing to be noted: If previous commits with AI generated messages are factored in, this will distort the style, therefore there would either be a system to separately store which commits are AI generated or just storing a single commit hash after which it can't be assumed that all commits are written by humans.

moritztim commented 10 months ago

@joeytwiddle I really like your tweaks, you should definitely make a pr!

joeytwiddle commented 10 months ago

@moritz-t-w Thanks, but my experience is that my tweaks don't work very well!

The AI always chooses to use conventional style (usually with the "refactor" label) even if previous commits used different tags, or didn't use conventional style at all.

moritztim commented 10 months ago

Well maybe that'll need some work but the other things you've done seem pretty reasonable