File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,11 @@ def __call__(
162
162
"default" : 0 ,
163
163
"help" : "length limit of the commit message; 0 for no limit" ,
164
164
},
165
+ {
166
+ "name" : "--allow-empty" ,
167
+ "action" : "store_true" ,
168
+ "help" : "Allow to create a commit without staging changes" ,
169
+ },
165
170
],
166
171
},
167
172
{
Original file line number Diff line number Diff line change @@ -73,14 +73,15 @@ def prompt_commit_questions(self) -> str:
73
73
return message
74
74
75
75
def __call__ (self ):
76
+ allow_empty : bool = self .arguments .get ("allow_empty" )
76
77
dry_run : bool = self .arguments .get ("dry_run" )
77
78
write_message_to_file : bool = self .arguments .get ("write_message_to_file" )
78
79
79
80
is_all : bool = self .arguments .get ("all" )
80
81
if is_all :
81
82
c = git .add ("-u" )
82
83
83
- if git .is_staging_clean () and not dry_run :
84
+ if git .is_staging_clean () and not ( dry_run or allow_empty ) :
84
85
raise NothingToCommitError ("No files added to staging!" )
85
86
86
87
if write_message_to_file is not None and write_message_to_file .is_dir ():
@@ -125,6 +126,11 @@ def __call__(self):
125
126
extra_args += " "
126
127
extra_args += "-s"
127
128
129
+ if allow_empty :
130
+ if extra_args :
131
+ extra_args += " "
132
+ extra_args += "--allow-empty"
133
+
128
134
c = git .commit (m , args = extra_args )
129
135
130
136
if c .return_code != 0 :
You can’t perform that action at this time.
0 commit comments