commitizen / cz-cli

The commitizen command line utility. #BlackLivesMatter
http://commitizen.github.io/cz-cli/
MIT License
16.77k stars 552 forks source link

Understanding: usage with commitlint #740

Open gaurav5430 opened 4 years ago

gaurav5430 commented 4 years ago

I am already using commitlint with conventional commits in my project to lint my commit messages as part of husky commit-msg githook.

I also want to have the ability to prompt users for correctly format messages while they are committing instead of checking before the actual commit, which commitlint enables with commitlint prompt Ofcourse, commitizen enables this as well with

"config": {
    "commitizen": {
      "path": "path/to/adapter"
    }
  },

Is there any benefit of using commitizen if I am using commitlint already?

Or, would it make sense to only use commitizen?

Does commitizen provide a commit-msg hook? as i would like to still lint my git commit messages if a user does not follow the prompt that commitizen provides for commit.

Assuming I do get some benefits by using both commitizen and commitlint, would it be better for me to use the commitlint adapter with config-conventional or cz-conventional-changelog?

castarco commented 4 years ago

Hi @gaurav5430 , in the issue #742 you can see how I configured commitizen + commitlint + husky. It works quite well.

gaurav5430 commented 4 years ago

@castarco I don't have any issues with making the setup work with cz-conventional-changelog and commitlint with husky, my question is more to understand whether I should be using cz-conventional-changelog at all if I am already using commitlint, should I just use the commitlint adapter instead of cz-conventional-changelog? And further, should I even use commitizen at all if I am already using commitlint? Can I not just use the commitlint prompt to setup a commit script same as git-cz, is there a benefit one approach provides over the other?

castarco commented 4 years ago

Oh, sorry. I will speak for my specific case.

I'm using commitizen as a wizard helper, while I still rely on commitlint to ensure that no one breaks the rules (I also execute commitlint in the CI pipeline to reject branches where the rules were not followed).

As far as I know, commitlint does not provide the kind of nice wizard that commitizen offers.

Also, I don't use the commitlint adapter, it was easier for me to keep both tools without integrating them too tightly.

gaurav5430 commented 4 years ago

commitlint does have a wizard: https://www.github.com/conventional-changelog/commitlint/tree/master/docs%2Fguides-use-prompt.md

Also, if you use commitlint as well as cz-conventional-changelog then you might be (assuming this because both of these repos are maintained separately) sourcing your conventional commits/rules from 2 different sources as commitlint has its own separate conventional commit config and cz-conventional-changelog has its own, Although it is highly unlikely that there are any discrepancies between these two but they are indeed separate sources to do the same checks.

To me it would make more sense to use the same tool/config for creating the commit as well as linting it. This can be achieved by using commitlint adapter with commitizen when creating the commit, which uses the same config as commitlint uses when linting the commit.

castarco commented 4 years ago

commitizen & cz-conventional-changelog are able to read and use the commitlint configuration (I checked it).

gaurav5430 commented 4 years ago

Oh Ok, so are you suggesting that when I use cz-conventional-changelog as well as commitlint, cz-conventional-changelog would use the commilint configuration by default?

gaurav5430 commented 4 years ago

commitizen & cz-conventional-changelog are able to read and use the commitlint configuration (I checked it).

As per my current understanding, commitizen would use the commitlint config if I use the commitlint adapter How does cz-conventional-changelog use the commitlint config?

Axedyson commented 3 years ago

How does cz-conventional-changelog use the commitlint config?

I would like to know that too

siddharth3586 commented 1 year ago

Seems there is no dependency between commitlint/husky and Commitizen. Both are separate solutions for tackling conventional commits and adhering to that.