ljnsn / cz-conventional-gitmoji

A commitizen plugin that combines gitmoji and conventional commits.
18 stars 4 forks source link

QUESTION: Are you able to use gitmoji commits to bump a package? #121

Closed jjfantini closed 8 months ago

jjfantini commented 10 months ago

I want to add gitmoji commits to my cookiecutter template. I have noticed in the past that the package doesn't bump at all using github actions when there is an emoji in the commit change type, only in the message?

Is it possible to have gitmoji commits with commitizen, and also have cz recognize the commits to bump the package version?

ljnsn commented 10 months ago

Yes, it's possible, it's set up in this repo itself :slightly_smiling_face:

You need to slightly adjust the example from the commitizen docs and add extra_requirements: "cz-conventional-gitmoji". You can check the workflow here. You might be interested in configuring the bump message to have a gitmoji too.

jjfantini commented 10 months ago

Okay thanks! I haven't been able to get it to work, and I have a package version in the GitHub sidebar.

I have tried to use cz_customize with custom values, bump map etc, but to no avail!

I will try again tomorrow, and let you know how it goes! I appreciate the help.

If I can't get it to work, would you be open to helping me set this up in a python package template?

I really like the use of vscode-commitizen plugin, to make committing easy and integrate into the software. using the CLI and having to git add . and then type cz commit and cycle through can add a lot of extra time. I am interested how you setup your workflow to do this!

I am willing to pay hahah I've been trying to set this up for a while now...

jjfantini commented 10 months ago

I am running into this error on bump:

Notice:  A new release of pip is available: 23.0.1 -> 23.3.2
Notice:  To update, run: pip install --upgrade pip
Commitizen version: 3.13.0
cz --no-raise 21 bump --yes --changelog --check-consistency --changelog-to-stdout >body.md
'cz_gitmoji' rule does not support bump

This happened when I use the cz commit CLI interface, and when I use commitizen plugin and when I use the text bar in source control on Cursor IDE.

Is there a way to fix this?

Check the error here

jjfantini commented 10 months ago

I am trying to integrate this workflow of commits into this cookie-cutter template

ljnsn commented 10 months ago

This error happens, because you set major_version_zero = true in your config. I'll have to look into why it fails with that, but for now it should work if you remove that setting.

If I can't get it to work, would you be open to helping me set this up in a python package template?

I don't have the time at the moment, but I hope you will be able to now :slightly_smiling_face:

I really like the use of vscode-commitizen plugin, to make committing easy and integrate into the software. using the CLI and having to git add . and then type cz commit and cycle through can add a lot of extra time. I am interested how you setup your workflow to do this!

I don't know about this vscode plugin, personally I use lazygit for most things git related. But it doesn't matter what you use, as long as you have the pre commit hook installed, the gitmoji will be prepended automatically and you don't have to cycle through the options.

jjfantini commented 10 months ago

Hmmm, it still does not pickup or correctly lint the commit to generate a new release? I guess that is the rules setup by cz-conventional-gitmoji

You can check this commit triggered the action from the branch, but then says

Notice:  A new release of pip is available: 23.0.1 -> 23.3.2
Notice:  To update, run: pip install --upgrade pip
Commitizen version: 3.13.0
cz --no-raise 21 bump --yes --changelog --check-consistency --changelog-to-stdout >body.md
🔖 bump(release): v0.2.0 → v0.2.0
tag to create: v0.2.0

[NO_COMMITS_TO_BUMP]
The commits found are not eligible to be bumped
Repository: jjfantini/gitmoji-test
Actor: jjfantini
Not pushing
Done.

for this commit 🥳 feat(test): texting ruff exe this should trigger a version bump

jjfantini commented 10 months ago

2.

You can also see here that when i run a hotfix(test): adding gitmoji hook message. The hook still doesn't add the emoji to the commit?

The only thing that has worked so far has been the CLI using cz commit. ANything else has not worked, with commitizen. BUt it is still just a commit and passed the commitizen checks? So not sure why emoji wouldn't append?? 🙈

jjfantini commented 10 months ago

It seems to be working when using the text input as writing my own custom commit, and including emojis myself. The gitmojify hook isn't working,

So,

CLI looks to be working and bumping, the emojis are included in the commit with CLI tool, no need for gitmojify Message bar in VSCode/ CURsor is working, manually writing emojis in, gitmojify is not working

ljnsn commented 9 months ago

for this commit 🥳 feat(test): texting ruff exe

this is not the gitmoji for a feature, either :sparkles: feat:... or just feat:... would trigger a bump.

hotfix(test): adding gitmoji hook

Yea, for this commit a gitmoji should be added (and is added for me).

Just to be clear, the pre-commit hook to add the gitmoji needs to run locally, this is not something that happens in CI (in case that's what you were expecting).

It seems to be working when using the text input as writing my own custom commit, and including emojis myself. The gitmojify hook isn't working,

Not sure what you mean by that, the point of the pre commit hook is to add the gitmoji automatically.

ljnsn commented 9 months ago

I would recommend you to set up a very simple repo, add commitizen and this plugin to it and make sure all functionality works. Something like what I described here. From there on you can gradually add the rest of your customizations.

Did you run this sequence of steps and do you get a gitmoji added to the commit message?

poetry new foo
cd foo
git init
poetry add pre-commit
# add your cz config to pyproject.toml
# add your pre-commit config
pre-commit install --install-hooks  --hook-type commit-msg
git add .
git commit -m "init: initial version"
# commit message: 🎉 init: initial commit
ljnsn commented 9 months ago

@jjfantini can this be closed? I think the original question has been answered.