commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

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

Open AdrianDC opened this issue 1 year ago • 4 comments

Description

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

  • Reworked over #1206 (commits follow-up)
  • Reimplementation of #592, authorship preserved

Checklist

  • [x] Add test cases to all the changes you introduce
  • [x] Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • [x] 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 avatar Aug 22 '24 01:08 AdrianDC

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.58%. Comparing base (120d514) to head (a442d70). Report is 508 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1217      +/-   ##
==========================================
+ Coverage   97.33%   97.58%   +0.24%     
==========================================
  Files          42       55      +13     
  Lines        2104     2608     +504     
==========================================
+ Hits         2048     2545     +497     
- Misses         56       63       +7     
Flag Coverage Δ
unittests 97.58% <100.00%> (+0.24%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 22 '24 01:08 codecov[bot]

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

Lee-W avatar Aug 22 '24 02:08 Lee-W

Coverage fixed :+1:.

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!

AdrianDC avatar Aug 22 '24 02:08 AdrianDC

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

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

AdrianDC avatar Aug 25 '24 01:08 AdrianDC

Rebased, ready to roll after 1206 :+1:

AdrianDC avatar Nov 10 '24 11:11 AdrianDC

1206 merged 🙌

Lee-W avatar Nov 16 '24 08:11 Lee-W

:+1:

AdrianDC avatar Nov 16 '24 11:11 AdrianDC