Skip to content

Commit c43d6d8

Browse files
committed
feat(commands/commit): abort commit if there is nothing to commit
1 parent 5efe4cc commit c43d6d8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

commitizen/commands/commit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
NO_ANSWERS = 5
1010
COMMIT_ERROR = 6
1111
NO_COMMIT_BACKUP = 7
12+
NOTHING_TO_COMMIT = 8
1213

1314

1415
class Commit:
@@ -21,6 +22,10 @@ def __init__(self, config: dict, arguments: dict):
2122
self.temp_file: str = os.path.join(tempfile.gettempdir(), "cz.commit.backup")
2223

2324
def __call__(self):
25+
if git.is_staging_clean():
26+
out.write("No files added to staging!")
27+
raise SystemExit(NOTHING_TO_COMMIT)
28+
2429
retry: bool = self.arguments.get("retry")
2530

2631
if retry:

0 commit comments

Comments
 (0)