File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,11 @@ def __call__(
162162 "default" : 0 ,
163163 "help" : "length limit of the commit message; 0 for no limit" ,
164164 },
165+ {
166+ "name" : "--allow-empty" ,
167+ "action" : "store_true" ,
168+ "help" : "Allow to create a commit without staging changes" ,
169+ },
165170 ],
166171 },
167172 {
Original file line number Diff line number Diff line change @@ -73,14 +73,15 @@ def prompt_commit_questions(self) -> str:
7373 return message
7474
7575 def __call__ (self ):
76+ allow_empty : bool = self .arguments .get ("allow_empty" )
7677 dry_run : bool = self .arguments .get ("dry_run" )
7778 write_message_to_file : bool = self .arguments .get ("write_message_to_file" )
7879
7980 is_all : bool = self .arguments .get ("all" )
8081 if is_all :
8182 c = git .add ("-u" )
8283
83- if git .is_staging_clean () and not dry_run :
84+ if git .is_staging_clean () and not ( dry_run or allow_empty ) :
8485 raise NothingToCommitError ("No files added to staging!" )
8586
8687 if write_message_to_file is not None and write_message_to_file .is_dir ():
@@ -125,6 +126,11 @@ def __call__(self):
125126 extra_args += " "
126127 extra_args += "-s"
127128
129+ if allow_empty :
130+ if extra_args :
131+ extra_args += " "
132+ extra_args += "--allow-empty"
133+
128134 c = git .commit (m , args = extra_args )
129135
130136 if c .return_code != 0 :
You can’t perform that action at this time.
0 commit comments