diff --git a/gitutility/async_tasks/async_workers.py b/gitutility/async_tasks/async_workers.py index 7117965..cc0e054 100644 --- a/gitutility/async_tasks/async_workers.py +++ b/gitutility/async_tasks/async_workers.py @@ -2696,13 +2696,50 @@ def run_repository_transformation_async( "--force" # Necessario perché il repo non è un clone "fresco" ] - git_commands.log_and_execute( - filter_repo_command, - working_directory=source_repo_path, - check=True, - log_output_level=logging.INFO - ) - log_handler.log_info(f"[Worker] History rewritten successfully.", func_name=func_name) + # Use a streaming execution so we can log progress lines as they arrive. + log_handler.log_info(f"[Worker] Running git-filter-repo (this may take a while)...", func_name=func_name) + try: + # Prepare startupinfo for Windows to hide console if possible + startupinfo = None + creationflags = 0 + if os.name == 'nt': + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + startupinfo.wShowWindow = subprocess.SW_HIDE + + proc = subprocess.Popen( + filter_repo_command, + cwd=source_repo_path, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + encoding='utf-8', + errors='replace', + startupinfo=startupinfo, + creationflags=creationflags, + ) + + aggregated_lines = [] + if proc.stdout: + for raw_line in proc.stdout: + line = raw_line.rstrip('\n') + aggregated_lines.append(line) + # Log each line so the UI log shows live progress + try: + log_handler.log_message(logging.INFO, f"[git-filter-repo] {line}", func_name=func_name) + except Exception: + # Logging must not break the worker; ignore logging errors + pass + + ret = proc.wait() + if ret != 0: + full_output = "\n".join(aggregated_lines) + raise GitCommandError(f"git-filter-repo failed with exit code {ret}", command=filter_repo_command, stderr=full_output) + + log_handler.log_info(f"[Worker] History rewritten successfully.", func_name=func_name) + + except FileNotFoundError as e: + raise GitCommandError("git-filter-repo not found. Ensure it is installed and in PATH.", command=filter_repo_command) from e # --- Passo 2: Rimuovere il remote 'origin' esistente (git-filter-repo lo fa già) --- log_handler.log_info(f"[Worker] Step 2: Verifying old remotes are removed (git-filter-repo should handle this)...", func_name=func_name)