feat(commit): add '--allow-empty' flag to commit command by AdrianDC · Pull Request #1217 · commitizen-tools/commitizen · GitHub
Skip to content

feat(commit): add '--allow-empty' flag to commit command - #1217

Merged
Lee-W merged 1 commit into
commitizen-tools:masterfrom
AdrianDC:allow-empty
Dec 6, 2024
Merged

feat(commit): add '--allow-empty' flag to commit command#1217
Lee-W merged 1 commit into
commitizen-tools:masterfrom
AdrianDC:allow-empty

Conversation

@AdrianDC

Copy link
Copy Markdown
Contributor

Description

feat(commit): add '--allow-empty' flag to commit command

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
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

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

Steps to Test This Pull Request

git cz c --allow-empty

Additional context

@AdrianDC AdrianDC changed the title Allow empty feat(commit): add '--allow-empty' flag to commit command Aug 22, 2024
@codecov

codecov Bot commented Aug 22, 2024

Copy link
Copy Markdown

@Lee-W

Lee-W commented Aug 22, 2024

Copy link
Copy Markdown
Member

Hi, thanks for contributing! would like to know why do we want --alow-empty. I thought we already have -- --allow-empty

@AdrianDC

Copy link
Copy Markdown
Contributor Author

Coverage fixed 👍.

Lee-W, apart from regular usage, it's because the staging area checks fail :

 $ cz c --allow-empty
-Invalid commitizen arguments were found: `--allow-empty`. Please use -- separator for extra git args

 $ cz c -- --allow-empty
-No files added to staging!

 # =======================
 $ pipx uninstall commitizen; pipx install .
 uninstalled commitizen! ✨ 🌟 ✨
   installed package commitizen 3.29.0, installed using Python 3.12.3
   These apps are now globally available
     - cz
     - git-cz
 done! ✨ 🌟 ✨

 # =======================
 $ cz c --allow-empty
 ? Select the type of change you are committing feat: A new feature. Correlates with MINOR in SemVer
 ? What is the scope of this change? (class or file name): (press [enter] to skip)
  test
 ? Write a short and imperative summary of the code changes: (lower case and no period)
  test
 ? Provide additional contextual information about the code changes: (press [enter] to skip)
  
 ? Is this a BREAKING CHANGE? Correlates with MAJOR in SemVer No
 ? Footer. Information about Breaking Changes and reference issues that this commit closes: (press [enter] to skip)
 

 feat(test): test


 [master 6b9618c5] feat(test): test

+Commit successful!

Comment thread commitizen/commands/commit.py
@AdrianDC

Copy link
Copy Markdown
Contributor Author

As discussed, I redid it all into -- --allow-empty support + implemented matching tests 👍.

Tested locally with cz c, cz c -- --allow-empty and cz c -s --allow-empty

@Lee-W Lee-W 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.

Looks like part of the code is also used in #1206. let's merge #1206 first and rebase that into this one and then I'll take a final review.

@AdrianDC

Copy link
Copy Markdown
Contributor Author

Rebased, ready to roll after 1206 👍

@Lee-W

Lee-W commented Nov 16, 2024

Copy link
Copy Markdown
Member

1206 merged 🙌

Signed-off-by: Adrian DC <radian.dc@gmail.com>
@AdrianDC

Copy link
Copy Markdown
Contributor Author

@Lee-W
Lee-W self-requested a review November 20, 2024 02:43
@Lee-W
Lee-W merged commit 636a069 into commitizen-tools:master Dec 6, 2024
@AdrianDC
AdrianDC deleted the allow-empty branch June 8, 2025 14:29
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.

2 participants