Feature/allow empty commit by Dranaxel · Pull Request #592 · commitizen-tools/commitizen · GitHub
Skip to content

Feature/allow empty commit - #592

Closed
Dranaxel wants to merge 5 commits into
commitizen-tools:masterfrom
Dranaxel:feature/allow-empty-commit
Closed

Feature/allow empty commit#592
Dranaxel wants to merge 5 commits into
commitizen-tools:masterfrom
Dranaxel:feature/allow-empty-commit

Conversation

@Dranaxel

@Dranaxel Dranaxel commented Sep 18, 2022

Copy link
Copy Markdown

Description

Add allow to create empty commit

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
    • One error on create commit message seem to be here before
  • Test the changes on the local machine manually
  • Update the documentation for the changes
    • Not needed

Expected behavior

Allow to invoke cz and create a commit without any change in it

Additional context

Relates to #247 & #590

@codecov

codecov Bot commented Sep 18, 2022

Copy link
Copy Markdown

Comment thread tests/commands/test_commit_command.py
@Dranaxel

Copy link
Copy Markdown
Author

@Lee-W Can you elaborate about what bother you in this test case ?

@Lee-W

Lee-W commented Sep 22, 2022

Copy link
Copy Markdown
Member

I'm kinda not sure whether this is correctly tested and will need sometime to figure it out. Will try to check it this week

@Dranaxel

Copy link
Copy Markdown
Author

Hi, I think we have a misunderstanding here. When I say "Empty commit" I mean a commit with no changes in it but we still need a message inside.

"footer": "",
}

commit_mock = mocker.patch("commitizen.git.commit")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dranaxel Thanks for correcting me. Yes, you're right. In that case, we probably should assert whether this function is called with --allow-empty. This can be done by something likeassert_called_with.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry i'm not sure about what you mean/how to use assert_called_with. Are you suggesting to assert the flag allow-empty was here when le command was launched ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert --allow-empty is actually passed into commitizen.git.commit when the operation above is executed

@noirbizarre noirbizarre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need rebase but I am OK with this one. I can definitely see use cases where you just want to force a commit without changes (like forcing rebuild to have updated dependencies).

Note: we might want the bump counter part for the same reason, aka. being able to force a release not containing commits eligible to changelog (aka. #723)

@bearomorphism

Copy link
Copy Markdown
Collaborator

Commitizen has cz commit -- --allow-empty now. Do we still need this change?

@Lee-W

Lee-W commented Aug 24, 2025

Copy link
Copy Markdown
Member

@Lee-W Lee-W closed this Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants