Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d36c0c2

Browse files
committed
fix(git): improves git error checking in get_commits
older version of git did not have the --author-date-order argument so it is best to report that kind of error.
1 parent d33f5fc commit d36c0c2

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

‎commitizen/exceptions.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ExitCode(enum.IntEnum):
2727
NOT_ALLOWED = 20
2828
NO_INCREMENT = 21
2929
UNRECOGNIZED_CHARACTERSET_ENCODING = 22
30+
GIT_COMMAND_ERROR = 23
3031

3132

3233
class CommitizenException(Exception):
@@ -153,3 +154,7 @@ class NotAllowed(CommitizenException):
153154

154155
class CharacterSetDecodeError(CommitizenException):
155156
exit_code = ExitCode.UNRECOGNIZED_CHARACTERSET_ENCODING
157+
158+
159+
class GitCommandError(CommitizenException):
160+
exit_code = ExitCode.GIT_COMMAND_ERROR

‎commitizen/git.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import List, Optional
77

88
from commitizen import cmd
9+
from commitizen.exceptions import GitCommandError
910

1011
UNIX_EOL = "\n"
1112
WINDOWS_EOL = "\r\n"
@@ -118,6 +119,8 @@ def get_commits(
118119
else:
119120
command = f"{git_log_cmd} {end}"
120121
c = cmd.run(command)
122+
if c.return_code != 0:
123+
raise GitCommandError(c.err)
121124
if not c.out:
122125
return []
123126

‎docs/exit_codes.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ These exit codes can be found in `commitizen/exceptions.py::ExitCode`.
3030
| NotAllowed | 20 | `--incremental` cannot be combined with a `rev_range` |
3131
| NoneIncrementExit | 21 | The commits found are not eligible to be bumped |
3232
| CharacterSetDecodeError | 22 | The character encoding of the command output could not be determined |
33+
| GitCommandError | 23 | Unexpected failure while calling a git command |

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /