git.get_commits error check
Description
git.get_commits could potentially fail silently.
The first commit is the fix.
See the git commit message for more info on all following commits (broken up for easier review).

The final commit also improves error checking in git.get_tags (closes #518).
Checklist
- [x] Add test cases to all the changes you introduce
- [x] Run
./scripts/formatand./scripts/testlocally 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
Fail fast behavior and better reports to the user when something goes wrong with git.
Some of the tests showed the command was failing for unexpected reasons (e.g. invalid commit range git log None..None).
Example of a silent failure that is now caught:
Without this change users with really old versions of git will see is "No commits found" but after the change:
GitCommandError: fatal: unrecognized argument: --author-date-order
- reason:
commands/changelog.pycallsgit.get_commitswith--author-date-orderbut this argument is not valid for older versions of it.
Steps to Test This Pull Request
- ran tests locally and formatted.
Additional context
Codecov Report
Merging #540 (7562808) into master (764861f) will increase coverage by
0.18%. The diff coverage is98.75%.
@@ Coverage Diff @@
## master #540 +/- ##
==========================================
+ Coverage 98.25% 98.44% +0.18%
==========================================
Files 39 39
Lines 1551 1603 +52
==========================================
+ Hits 1524 1578 +54
+ Misses 27 25 -2
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 98.44% <98.75%> (+0.18%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| commitizen/git.py | 99.27% <97.61%> (-0.73%) |
:arrow_down: |
| commitizen/__version__.py | 100.00% <100.00%> (ø) |
|
| commitizen/bump.py | 100.00% <100.00%> (ø) |
|
| commitizen/changelog.py | 100.00% <100.00%> (+0.56%) |
:arrow_up: |
| commitizen/cmd.py | 100.00% <100.00%> (ø) |
|
| commitizen/commands/changelog.py | 98.85% <100.00%> (+2.25%) |
:arrow_up: |
| commitizen/commands/commit.py | 98.43% <100.00%> (+0.02%) |
:arrow_up: |
| commitizen/commands/init.py | 91.66% <100.00%> (ø) |
|
| commitizen/config/json_config.py | 100.00% <100.00%> (ø) |
|
| commitizen/config/yaml_config.py | 100.00% <100.00%> (ø) |
|
| ... and 4 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Thanks a lot!