Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(conf): handle parse error when init #856

Merged
merged 4 commits into from
Sep 22, 2023

Conversation

Bogay
Copy link
Contributor

@Bogay Bogay commented Sep 21, 2023

Description

If there is already a config file with wrong format in cwd, cz would failed to parse and the exception is unhandled. #729 have fixed that for json config, but yaml and toml are not.

Fixes #577

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

cz should report there is an error when parsing config file.

Steps to Test This Pull Request

Execute following commands:

mkdir /tmp/cz-init
cd /tmp/init
echo 'i am not toml' > .cz.toml
# or test yaml format
# echo 'i: am: not: yaml' > .cz.yaml
cz init

and you will see error message like this:

Failed to parse .cz.toml: Invalid key "invalid content" at line 1 col 15

or this:

Failed to parse .cz.yaml: mapping values are not allowed here
  in "<byte string>", line 1, column 6:
    i: am: not: yaml
         ^

Additional context

@codecov
Copy link

codecov bot commented Sep 22, 2023

@woile woile merged commit 7ffb895 into commitizen-tools:master Sep 22, 2023
18 checks passed
@Bogay Bogay deleted the fix/init-invalid-content branch December 25, 2023 05:19
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.

cz commands failed if there is already a config file but in wrong format
2 participants