@@ -51,15 +51,15 @@ def __init__(self, config: BaseConfig, arguments: CommitArgs) -> None:
51
51
self .encoding = config .settings ["encoding" ]
52
52
self .cz = factory .committer_factory (self .config )
53
53
self .arguments = arguments
54
- self .temp_file : str = get_backup_file_path ()
54
+ self .backup_file_path = get_backup_file_path ()
55
55
56
56
def _read_backup_message (self ) -> str | None :
57
57
# Check the commit backup file exists
58
- if not os . path . isfile ( self . temp_file ):
58
+ if not self . backup_file_path . is_file ( ):
59
59
return None
60
60
61
61
# 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 :
63
63
return f .read ().strip ()
64
64
65
65
def _prompt_commit_questions (self ) -> str :
@@ -108,10 +108,10 @@ def manual_edit(self, message: str) -> str:
108
108
109
109
def _get_message (self ) -> str :
110
110
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 :
113
113
raise NoCommitBackupError ()
114
- return m
114
+ return commit_message
115
115
116
116
if self .config .settings .get ("retry_after_failure" ) and not self .arguments .get (
117
117
"no_retry"
@@ -139,29 +139,29 @@ def __call__(self) -> None:
139
139
if write_message_to_file is not None and write_message_to_file .is_dir ():
140
140
raise NotAllowed (f"{ write_message_to_file } is a directory" )
141
141
142
- m = self ._get_message ()
142
+ commit_message = self ._get_message ()
143
143
if self .arguments .get ("edit" ):
144
- m = self .manual_edit (m )
144
+ commit_message = self .manual_edit (commit_message )
145
145
146
- out .info (f"\n { m } \n " )
146
+ out .info (f"\n { commit_message } \n " )
147
147
148
148
if write_message_to_file :
149
149
with smart_open (write_message_to_file , "w" , encoding = self .encoding ) as file :
150
- file .write (m )
150
+ file .write (commit_message )
151
151
152
152
if dry_run :
153
153
raise DryRunExit ()
154
154
155
155
if self .config .settings ["always_signoff" ] or signoff :
156
156
extra_args = f"{ extra_args } -s" .strip ()
157
157
158
- c = git .commit (m , args = extra_args )
158
+ c = git .commit (commit_message , args = extra_args )
159
159
if c .return_code != 0 :
160
160
out .error (c .err )
161
161
162
162
# 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 )
165
165
166
166
raise CommitError ()
167
167
@@ -170,7 +170,7 @@ def __call__(self) -> None:
170
170
return
171
171
172
172
with contextlib .suppress (FileNotFoundError ):
173
- os . remove ( self .temp_file )
173
+ self .backup_file_path . unlink ( )
174
174
out .write (c .err )
175
175
out .write (c .out )
176
176
out .success ("Commit successful!" )
0 commit comments