diff --git a/gitsync_tool/app.py b/gitsync_tool/app.py index c5c91fe..9d01d0c 100644 --- a/gitsync_tool/app.py +++ b/gitsync_tool/app.py @@ -2082,7 +2082,6 @@ class GitSvnSyncApp: GitignoreEditorWindow( master=self.master, # Parent window gitignore_path=gitignore_path, - logger_ignored=None, # Logger no longer passed on_save_success_callback=self._handle_gitignore_save # Method to call on save ) # Code execution pauses here until the editor window is closed @@ -2200,61 +2199,6 @@ class GitSvnSyncApp: } ) - def open_gitignore_editor(self): - """ Opens the .gitignore editor window (Synchronous GUI action). """ - # This action is synchronous as it opens a modal dialog - func_name: str = "open_gitignore_editor" - log_handler.log_info( - f"--- Action Triggered: Edit .gitignore ---", func_name=func_name - ) - # Ensure main frame exists - if not hasattr(self, "main_frame") or not self.main_frame.winfo_exists(): - return - - # Validate repo path and readiness - self.main_frame.update_status_bar("Processing: Opening .gitignore editor...") - svn_path: Optional[str] = self._get_and_validate_svn_path("Edit .gitignore") - if not svn_path or not self._is_repo_ready(svn_path): - log_handler.log_warning( - "Cannot edit .gitignore: Repo path invalid/not ready.", - func_name=func_name - ) - self.main_frame.show_error( - "Action Failed", "Select a valid and prepared repository first." - ) - self.main_frame.update_status_bar("Edit failed: Repo not ready.") - return - - # Construct path and open editor window - gitignore_path: str = os.path.join(svn_path, ".gitignore") - log_handler.log_debug( - f"Target .gitignore path: {gitignore_path}", func_name=func_name - ) - status_after_edit: str = "Ready." # Default status after editor closes - - try: - log_handler.log_debug("Opening GitignoreEditorWindow...", func_name=func_name) - # Open the modal editor window, passing the callback for successful save - GitignoreEditorWindow( - master=self.master, # Parent window - gitignore_path=gitignore_path, - logger_ignored=None, # Logger no longer passed - on_save_success_callback=self._handle_gitignore_save # Method to call on save - ) - # Code execution pauses here until the editor window is closed - log_handler.log_debug("Gitignore editor window closed.", func_name=func_name) - # Update status bar only if no async operation was started by the callback - if not self.main_frame.status_bar_var.get().startswith("Processing"): - self.main_frame.update_status_bar(status_after_edit) - except Exception as e: - # Handle errors opening the editor - log_handler.log_exception( - f"Error opening or running .gitignore editor: {e}", func_name=func_name - ) - status_after_edit = "Error opening .gitignore editor." - self.main_frame.show_error("Editor Error", f"Could not open editor:\n{e}") - self.main_frame.update_status_bar(status_after_edit) - def refresh_changed_files_list(self): """ Starts async operation to refresh the list of changed files. """ func_name: str ="refresh_changed_files_list" @@ -3956,6 +3900,44 @@ class GitSvnSyncApp: f"Failed to recover GUI after queue processing error: {recovery_e}", func_name=func_name ) + + def _handle_gitignore_save(self): + """ + Callback executed after .gitignore is saved successfully by the editor. + Starts an asynchronous task to check for and untrack files if necessary. + """ + func_name: str = "_handle_gitignore_save" + log_handler.log_info( + "Callback: .gitignore saved. Starting async untrack check.", + func_name=func_name + ) + # Ensure main frame exists + if not hasattr(self, "main_frame") or not self.main_frame.winfo_exists(): + return + + # Validate repo path and readiness + svn_path: Optional[str] = self._get_and_validate_svn_path("Untrack Check after Gitignore Save") + if not svn_path or not self._is_repo_ready(svn_path): + log_handler.log_error( + "Cannot start untrack check: Invalid/Not ready path.", + func_name=func_name + ) + self.main_frame.update_status_bar( + "Error: Untrack check failed (invalid path)." + ) + return + + # Prepare args and start the untrack worker + args: tuple = (self.action_handler, svn_path) + self._start_async_operation( + worker_func=async_workers.run_untrack_async, + args_tuple=args, + context_dict={ + "context": "_handle_gitignore_save", # Context identifies origin + "status_msg": "Checking files to untrack", + "committed_flag_possible": True # Untracking involves a commit + } + ) # --- Application Entry Point --- diff --git a/gitsync_tool/async_tasks/async_workers.py b/gitsync_tool/async_tasks/async_workers.py index 871fc82..26e1142 100644 --- a/gitsync_tool/async_tasks/async_workers.py +++ b/gitsync_tool/async_tasks/async_workers.py @@ -1415,12 +1415,12 @@ def run_get_ahead_behind_async( ) else: parts: List[str] = [] - if ahead > 0: - plural_a = "s" if ahead > 1 else "" - parts.append(f"{ahead} commit{plural_a} ahead") - if behind > 0: - plural_b = "s" if behind > 1 else "" - parts.append(f"{behind} commit{plural_b} behind") + if ahead_count > 0: + plural_a = "s" if ahead_count > 1 else "" + parts.append(f"{ahead_count} commit{plural_a} ahead") + if behind_count > 0: + plural_b = "s" if behind_count > 1 else "" + parts.append(f"{behind_count} commit{plural_b} behind") message = ( f"Branch '{local_branch}' is " + " and ".join(parts)