@@ -51,15 +51,15 @@ def __init__(self, config: BaseConfig, arguments: CommitArgs) -> None:
5151 self .encoding = config .settings ["encoding" ]
5252 self .cz = factory .committer_factory (self .config )
5353 self .arguments = arguments
54- self .temp_file : str = get_backup_file_path ()
54+ self .backup_file_path = get_backup_file_path ()
5555
5656 def _read_backup_message (self ) -> str | None :
5757 # Check the commit backup file exists
58- if not os . path . isfile ( self . temp_file ):
58+ if not self . backup_file_path . is_file ( ):
5959 return None
6060
6161 # Read commit message from backup
62- with open (self .temp_file , encoding = self .encoding ) as f :
62+ with open (self .backup_file_path , encoding = self .encoding ) as f :
6363 return f .read ().strip ()
6464
6565 def _prompt_commit_questions (self ) -> str :
@@ -108,10 +108,10 @@ def manual_edit(self, message: str) -> str:
108108
109109 def _get_message (self ) -> str :
110110 if self .arguments .get ("retry" ):
111- m = self ._read_backup_message ()
112- if m is None :
111+ commit_message = self ._read_backup_message ()
112+ if commit_message is None :
113113 raise NoCommitBackupError ()
114- return m
114+ return commit_message
115115
116116 if self .config .settings .get ("retry_after_failure" ) and not self .arguments .get (
117117 "no_retry"
@@ -139,29 +139,29 @@ def __call__(self) -> None:
139139 if write_message_to_file is not None and write_message_to_file .is_dir ():
140140 raise NotAllowed (f"{ write_message_to_file } is a directory" )
141141
142- m = self ._get_message ()
142+ commit_message = self ._get_message ()
143143 if self .arguments .get ("edit" ):
144- m = self .manual_edit (m )
144+ commit_message = self .manual_edit (commit_message )
145145
146- out .info (f"\n { m } \n " )
146+ out .info (f"\n { commit_message } \n " )
147147
148148 if write_message_to_file :
149149 with smart_open (write_message_to_file , "w" , encoding = self .encoding ) as file :
150- file .write (m )
150+ file .write (commit_message )
151151
152152 if dry_run :
153153 raise DryRunExit ()
154154
155155 if self .config .settings ["always_signoff" ] or signoff :
156156 extra_args = f"{ extra_args } -s" .strip ()
157157
158- c = git .commit (m , args = extra_args )
158+ c = git .commit (commit_message , args = extra_args )
159159 if c .return_code != 0 :
160160 out .error (c .err )
161161
162162 # Create commit backup
163- with smart_open (self .temp_file , "w" , encoding = self .encoding ) as f :
164- f .write (m )
163+ with smart_open (self .backup_file_path , "w" , encoding = self .encoding ) as f :
164+ f .write (commit_message )
165165
166166 raise CommitError ()
167167
@@ -170,7 +170,7 @@ def __call__(self) -> None:
170170 return
171171
172172 with contextlib .suppress (FileNotFoundError ):
173- os . remove ( self .temp_file )
173+ self .backup_file_path . unlink ( )
174174 out .write (c .err )
175175 out .write (c .out )
176176 out .success ("Commit successful!" )
0 commit comments