chshersh / zbg

✨ Zero Bullshit Git
Mozilla Public License 2.0
187 stars 11 forks source link

Format the commit message #33

Closed etorreborre closed 11 months ago

etorreborre commented 11 months ago

One thing that I miss with zbg is a way to format the commit message like with the cmt Haskell tool.

zbg new already goes in the direction of having some convention for branch names (with the user.login prefix), I think it would be good to go one step further with commit messages. This could be totally optional:

chshersh commented 11 months ago

Hi @etorreborre 👋🏻

Thanks for the idea! I'm not familiar with the cmt tool but it looks cool! 🚀

I'm hesitant to reimplement an entire templating tool here and I personally don't use commit templates. If you have a .cmt commit template, can't you just use cmt instead of zbg commit?

On a separate note, I discovered that git itself supports commit templates natively via the commit.template option in .gitconfig:

It might not be as flexible and powerful as cmt but IMO it's more portable and makes your workflow more universal.

Since zbg commit without arguments will call git add . followed by git commit, the latter will use commit.template and you can go from here.

Would it be enough?

etorreborre commented 11 months ago

My company is currently using (and enforcing) commit messages along the conventialcommits format. This is where cmt is useful. There's less chance of a making a mistake, and it saves some typing when prefixing the message with refactor(rust).

Thanks for the pointer on git commit templates, I didn't know that such a thing existed. I will experiment with it. I totally understand why you would not want to re-implement a template system, no worries.