File tree 3 files changed +15
-6
lines changed
3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 66
66
"action" : "store_true" ,
67
67
"help" : "Sign off the commit" ,
68
68
},
69
+ {
70
+ "name" : "--allow-empty" ,
71
+ "action" : "store_true" ,
72
+ "help" : "Allow to create commit on an empty staging" ,
73
+ },
69
74
],
70
75
},
71
76
{
Original file line number Diff line number Diff line change @@ -62,10 +62,14 @@ def prompt_commit_questions(self) -> str:
62
62
return cz .message (answers )
63
63
64
64
def __call__ (self ):
65
- dry_run : bool = self .arguments .get ("dry_run" )
66
-
65
+ args = []
67
66
allow_empty : bool = self .arguments .get ("allow_empty" )
68
67
68
+ if allow_empty :
69
+ args .append ("--allow-empty" )
70
+
71
+ dry_run : bool = self .arguments .get ("dry_run" )
72
+
69
73
if git .is_staging_clean () and not (dry_run or allow_empty ):
70
74
raise NothingToCommitError ("No files added to staging!" )
71
75
@@ -84,9 +88,9 @@ def __call__(self):
84
88
signoff : bool = self .arguments .get ("signoff" )
85
89
86
90
if signoff :
87
- c = git . commit ( m , "-s" )
88
- else :
89
- c = git .commit (m )
91
+ args . append ( "-s" )
92
+
93
+ c = git .commit (m , * args )
90
94
91
95
if c .return_code != 0 :
92
96
out .error (c .err )
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def test_commit(config, mocker):
38
38
success_mock = mocker .patch ("commitizen.out.success" )
39
39
40
40
commands .Commit (config , {})()
41
- success_mock .assert_called_once ()
41
+ success_mock .assert_called_once ()
42
42
43
43
44
44
@pytest .mark .usefixtures ("staging_is_clean" )
You can’t perform that action at this time.
0 commit comments