commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

Add a `--quiet` option

Open jenstroeger opened this issue 3 years ago • 4 comments

Description

Running cz bump --yes in a Windows runner using PowerShell threw the following exception today:

Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\a\...\.venv\Scripts\cz.exe\__main__.py", line 7, in <module>
  File "D:\a\...\.venv\lib\site-packages\commitizen\cli.py", line 383, in main
    args.func(conf, vars(args))()
  File "D:\a\...\.venv\lib\site-packages\commitizen\commands\bump.py", line 174, in __call__
    out.write(information)
  File "D:\a\...\.venv\lib\site-packages\commitizen\out.py", line 8, in write
    print(value, *args)
  File "D:\a\...\.venv\lib\site-packages\colorama\ansitowin32.py", line 47, in write
    self.__convertor.write(text)
  File "D:\a\...\.venv\lib\site-packages\colorama\ansitowin32.py", line 170, in write
    self.write_and_convert(text)
  File "D:\a\...\.venv\lib\site-packages\colorama\ansitowin32.py", line 198, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "D:\a\...\.venv\lib\site-packages\colorama\ansitowin32.py", line 203, in write_plain_text
    self.wrapped.write(text[start:end])
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2192' in position 20: character maps to <undefined>

The issue here is '\u2192' which is the in the bump commit message. I’ve not checked which character encoding PowerShell expects here or where this particular error originates.

However, I thought it would be useful to add a --quiet option to cz which would allow me to suppress any output of the tool. Redirecting to $null is a poor solution to the problem; so is --quiet but…

Steps to reproduce

Use

bump_message = "bump: release $current_version → $new_version" 

and run cz bump on a Windows with PowerShell. As mentioned above, I’m not sure how the PowerShell is set up for Github hosted Windows runners, but it should just fail on the default runner.

Current behavior

Exception as shown above.

Desired behavior

Version bump and output into the terminal.

Screenshots

No response

Environment

  • Pinned "commitizen ==2.28.1" to avoid issue: https://github.com/commitizen-tools/commitizen/issues/544
  • CPython 3.10.5 on Windows
  • Github Windows runner:
     Current runner version: '2.294.0'
     Operating System
       Microsoft Windows Server 2022
       10.0.20348
       Datacenter
     Virtual Environment
       Environment: windows-2022
       Version: 20220731.1
       Included Software: https://github.com/actions/virtual-environments/blob/win22/20220731.1/images/win/Windows2022-Readme.md
       Image Release: https://github.com/actions/virtual-environments/releases/tag/win22%2F20220731.1
     Virtual Environment Provisioner
       1.0.0.0-main-20220725-1
    

jenstroeger avatar Aug 04 '22 02:08 jenstroeger

All the latest errors are related to the chardet I think

woile avatar Aug 04 '22 07:08 woile

Wondering is it be solved by https://github.com/commitizen-tools/commitizen/pull/550?

Lee-W avatar Aug 07 '22 03:08 Lee-W

No, because predicting text encoding from a given byte stream has always a degree of uncertainty (especially for small sample sets) — see also Character set confusion.

jenstroeger avatar Aug 07 '22 10:08 jenstroeger

How about the latest release? I don't have a windows machine to check this 🤦‍♂️

Lee-W avatar Aug 14 '22 06:08 Lee-W

Closing. Feel free to reopen if it still happens

woile avatar Apr 28 '23 13:04 woile