@@ -33,13 +33,16 @@ def __init__(self, config: BaseConfig, arguments: dict):
3333 self .arguments = arguments
3434 self .temp_file : str = os .path .join (
3535 tempfile .gettempdir (),
36- "cz.commit{user}.backup" .format (user = os .environ .get ("USER" , "" )),
36+ "cz.commit%{user}%{project_root}.backup" .format (
37+ user = os .environ .get ("USER" , "" ),
38+ project_root = str (git .find_git_project_root ()).replace ("/" , "%" ),
39+ ),
3740 )
3841
39- def read_backup_message (self ) -> str :
42+ def read_backup_message (self ) -> str | None :
4043 # Check the commit backup file exists
4144 if not os .path .isfile (self .temp_file ):
42- raise NoCommitBackupError ()
45+ return None
4346
4447 # Read commit message from backup
4548 with open (self .temp_file , encoding = self .encoding ) as f :
@@ -65,7 +68,7 @@ def prompt_commit_questions(self) -> str:
6568
6669 def __call__ (self ):
6770 dry_run : bool = self .arguments .get ("dry_run" )
68- write_message_to_file = self .arguments .get ("write_message_to_file" )
71+ write_message_to_file : bool = self .arguments .get ("write_message_to_file" )
6972
7073 is_all : bool = self .arguments .get ("all" )
7174 if is_all :
@@ -78,9 +81,17 @@ def __call__(self):
7881 raise NotAllowed (f"{ write_message_to_file } is a directory" )
7982
8083 retry : bool = self .arguments .get ("retry" )
84+ no_retry : bool = self .arguments .get ("no_retry" )
85+ retry_after_failure : bool = self .config .settings .get ("retry_after_failure" )
8186
8287 if retry :
8388 m = self .read_backup_message ()
89+ if m is None :
90+ raise NoCommitBackupError ()
91+ elif retry_after_failure and not no_retry :
92+ m = self .read_backup_message ()
93+ if m is None :
94+ m = self .prompt_commit_questions ()
8495 else :
8596 m = self .prompt_commit_questions ()
8697
0 commit comments