commitizen
commitizen copied to clipboard
Report hook installation fail
Description
This PR make cz
report errors if user want to install pre-commit hook and failed, which fixs #428.
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
- [x] Update the documentation for the changes
Expected behavior
Run cz init
will print error if there is something wrong.
❯ cz init
? 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
pre-commit is not installed in current environement.
Installation failed. See error outputs for more information.
And the exit code should not be 0.
❯ echo $?
24
Steps to Test This Pull Request
# Run `cz init` with default choices
cz init
# Check the exit code should not be 0
test $? != 0
Additional context
I found that TestPreCommitCases
has some duplicated code. Should they be extracted to methods?
Codecov Report
Base: 97.92% // Head: 98.03% // Increases project coverage by +0.10%
:tada:
Coverage data is based on head (
a23ef07
) compared to base (db42a95
). Patch coverage: 85.96% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## master #578 +/- ##
==========================================
+ Coverage 97.92% 98.03% +0.10%
==========================================
Files 35 39 +4
Lines 1252 1676 +424
==========================================
+ Hits 1226 1643 +417
- Misses 26 33 +7
Flag | Coverage Δ | |
---|---|---|
unittests | 98.03% <85.96%> (+0.10%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
commitizen/commands/init.py | 87.93% <84.00%> (-3.74%) |
:arrow_down: |
commitizen/__version__.py | 100.00% <100.00%> (ø) |
|
commitizen/commands/changelog.py | 98.86% <100.00%> (ø) |
|
commitizen/commands/check.py | 100.00% <100.00%> (ø) |
|
commitizen/exceptions.py | 100.00% <100.00%> (ø) |
|
commitizen/bump.py | 100.00% <0.00%> (ø) |
|
commitizen/__init__.py | 100.00% <0.00%> (ø) |
|
commitizen/changelog.py | 99.43% <0.00%> (ø) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
I found that TestPreCommitCases has some duplicated code. Should they be extracted to methods?
Yep that would be great
@Lee-W I think it's ready to be reviewed.
@Lee-W it's done 👍