Skip to content

Commit b0682d5

Browse files
committed
feat(commit): added a --allow-empty flag to commit command
1 parent 4f4fb4d commit b0682d5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

commitizen/commands/commit.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def prompt_commit_questions(self) -> str:
6464
def __call__(self):
6565
dry_run: bool = self.arguments.get("dry_run")
6666

67-
if git.is_staging_clean() and not dry_run:
67+
allow_empty: bool = self.arguments.get("allow_empty")
68+
69+
if git.is_staging_clean() and not (dry_run or allow_empty):
6870
raise NothingToCommitError("No files added to staging!")
6971

7072
retry: bool = self.arguments.get("retry")

tests/commands/test_commit_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_commit(config, mocker):
3838
success_mock = mocker.patch("commitizen.out.success")
3939

4040
commands.Commit(config, {})()
41-
success_mock.assert_called_once()
41+
success_mock.assert_called_once()
4242

4343

4444
@pytest.mark.usefixtures("staging_is_clean")

0 commit comments

Comments
 (0)