DEV Community

Cover image for OpenCommit: GPT generates impressive commits in 1 second πŸ€―πŸ”« (open-source)
Dima Sukharev
Dima Sukharev

Posted on • Updated on

OpenCommit: GPT generates impressive commits in 1 second πŸ€―πŸ”« (open-source)

first β€” let's grow my twitter, so i can tell about my inventions quicker and make the world even better place (or not, idk)


I've been struggling making commit messages since 2017.

When you think of a commit message β€” you switch context from writing code. When you switch context β€” you waste time. Wasting time is lame.

I usually made 1 line commits like "amends", "fixed bug", "refactoring", "refactoring 2", "final refactoring" and then tried to come up with a good general message when merging a branch to production.

It has changed with THE FIRST AI REVOLUTION :)) I mean all this GPTs..

Two weeks ago I open-sourced OpenCommit. It can answer WHY the change was done if you change model to GPT-4 in settings! Insane.

opencommit β€” comparison

The lib uses conventional commits convention which makes commits meaningful. You can also turn on GitMoji setting if you like. And select different languages and many other features (I got 12 PRs so far)

Simply install it with npm:

npm i -g opencommit
Enter fullscreen mode Exit fullscreen mode

After installing type oc and hit "Enter" in a terminal:

oc
Enter fullscreen mode Exit fullscreen mode

If you want OpenCommit to be used by your IDE do:

oc hook set
Enter fullscreen mode Exit fullscreen mode

That's it.

For more features read the docs.

opencommit.gif

you may follow my twitter or not


btw, i have one more great tool for making GPT write extremely accurate code for you https://dev.to/disukharev/aitdd-ai-cli-for-tdd-you-write-the-test-ai-makes-it-green-32bn

Latest comments (69)

Collapse
 
gamoreli profile image
Gabriel Moreli

Getting this error while trying to generate the commit message

connect ECONNREFUSED ::1:80

Anyone having the same issue?

Collapse
 
dbolser profile image
Dan Bolser

Hello. Love the religious wars, very educational and very respectful.

Please can you create a bot that 'unpick's (pun intended) my spaghetti diff commits into nice atomic commits following git flow conventions, running tests and squashing bug fixes?

kthxbi

Collapse
 
pauldmurphy profile image
Paul Murphy • Edited

You could try something like this...

Company policy requires commit messages explain the "why" of the check-in and not the "what". Can you ask me questions regarding why I made the changes in this commit and then write a professional, technically accurate, succinct commit message for me?

Collapse
 
smonff profile image
🌌 SΓ©bastien FeugΓ¨re β˜” • Edited

If we don’t know why we work on some bug fix or feature, and need GPT to write our commit messages, I don’t think that an AI will be helpful. Writing a commit message is a full part of communicating with other and make important reflexion progress. If we delegate that, I am almost sure we miss something.

Collapse
 
lukeocodes profile image
@lukeocodes πŸ•ΉπŸ‘¨β€πŸ’»

This is a great idea. I'd love to see you edit the prompts to have GPT follow conventional commits in it's output.

Collapse
 
andreisuslov profile image
Andrei Suslov • Edited

Can I force the commit and push immediately after running "oc" without checking the message?

Collapse
 
explorer14 profile image
Aman Agrawal

When you think of a commit message β€” you switch context from writing code. When you switch context β€” you waste time. Wasting time is lame

Thinking about what you are doing is not a waste of time its a part of our job as engineers! πŸ™‚

Collapse
 
stanleysathler profile image
Stanley Sathler • Edited

Impressive how many people put so much effort to invalidate your creation.

"Commits should describe WHY, not WHAT."

Okay. Push a bunch of commits generated by the extension. Before you merge your PR, just squash it and name it whatever you prefer. Done. You got your WHY, but spent no time writing a bunch of other mini commits that probably no one cares after your PR is merged.

Nice work Dima! Not every innovation fits everyone unfortunately.

Collapse
 
cicko profile image
Rudolf Cicko

First of all no good dev commits like the "before", secondly, I doubt GPT is able to understand the scope of a task and the project. The commit message should be a meaningful short message to understand what was done in the scope of the task/project, and not just list all the changes, which can be observed by checking the diff.

Collapse
 
holiq profile image
Holiq Ibrahim

How about this? Who is better?
aicommits

Collapse
 
andreisuslov profile image
Andrei Suslov

Their messages are in past tense lol

Collapse
 
deathlybower959 profile image
DeathlyBower959 • Edited

Isnt this bad to use? It defeats the purpose of a commit message, no? From my understanding, a commit message should be a description of WHY the changes happened, not WHAT happened.

Which would you rather read?

"Fix: Database overflow error"
"Add if statement to make sure index does not exceed database length"

I would much prefer to read the more concise, first message, as it explains the purpose of the code changed, and then the diff checker will show me exactly what is changed.

I'm not attacking this project, it looks quite cool, but saying "what" changed seems incorrect imo. Just learn how to write proper commit messages, it's not difficult to learn.

Edit: I see that you posted the same article 3 times with different names, so I know none of them are trustworthy and are just spam lol.

Collapse
 
hellowwworld profile image
hellowwworld

Use git-flow, get a life 😁 there's better things to do than write commit messages by yourself

Collapse
 
chriisduran profile image
Christopher Duran

i donΒ΄t know Rick..

I prefer write by myself the commits.

Collapse
 
dilenio profile image
Dilenio Enderle

I appreciate it!

Collapse
 
guydahn profile image
GuyDahn

Commits are the one thing i do right, why take it away from me? :<

Collapse
 
pterpmnta profile image
Pedro Pimienta M.

Thanks for the information.