-
-
Notifications
You must be signed in to change notification settings - Fork 301
Closed
@Bogay
Description
Description
The cz init
command may fail unexpectedly under some condition.
In this case, the error may be caused by my command output is not encoding by UTF-8. I have tried to decode the output using CP950 and after that I can see a error message: 'pre-commit' 不是內部或外部命令、可執行的程式或批次檔。
, which means that PowerShell can not find pre-commit
to execute, because I forget to install it before run cz init
.
Steps to reproduce
- Create a empty directory
- Enter the directory
- execute
cz init
and use the default setttings
Current behavior
It will raise UnicodeDecodeError
, logs are attached below:
? Please choose a supported config file: (default: pyproject.toml) pyproject.toml ? Please choose a cz (commit rule): (default: cz_conventional_commits) cz_conventional_commits No Existing Tag. Set tag to v0.0.1 ? Please enter the correct version format: (default: "$version") ? Do you want to install pre-commit hook? Yes Traceback (most recent call last): File "c:\users\aa\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\aa\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\AA\AppData\Local\Programs\Python\Python38\Scripts\cz.exe\__main__.py", line 7, in <module> File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\cli.py", line 301, in main args.func(conf, vars(args))() File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\commands\init.py", line 43, in __call__ self._install_pre_commit_hook() File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\commands\init.py", line 144, in _install_pre_commit_hook c = cmd.run("pre-commit install --hook-type commit-msg") File "c:\users\aa\appdata\local\programs\python\python38\lib\site-packages\commitizen\cmd.py", line 23, in run return Command(stdout.decode(), stderr.decode(), stdout, stderr, return_code) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa4 in position 13: invalid start byte
Desired behavior
Successfully initialize commitizen project.
Environment
- commitizen version: 2.18.1
- python version: 3.8.7
- operating system: Windows (OS buid: 19043.1237)
- shell: PowerShell 7.1.3