From f51701818a1905493a646d3bcba927aceefdccc1 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Wed, 26 Nov 2025 10:58:19 -0600 Subject: [PATCH] wip: feat: workspace tmux remove --- pyproject.toml | 4 ++-- workspaces.py | 22 +++++++--------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 562fefa..1dffd73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,10 +75,10 @@ select = [ "RSE", # flake8-raise "RET", # flake8-return # "SLF", # flake8-self -# "SIM", # flake8-simplify + "SIM", # flake8-simplify "TID", # flake8-tidy-imports "TCH", # flake8-type-checking -# "INT", # flake8-gettext + "INT", # flake8-gettext "ARG", # flake8-unused-arguments "PTH", # flake8-use-pathlib "ERA", # eradicate diff --git a/workspaces.py b/workspaces.py index 90072d5..5ca4055 100755 --- a/workspaces.py +++ b/workspaces.py @@ -838,9 +838,8 @@ def remove_workspace( problems.append(f"{wt.name}: dirty working tree on '{branch}'") # Only care about "unpushed commits" if the branch is NOT integrated into main. - if repo is not None and branch != "?" and not integrated: - if has_unpushed_commits(wt): - problems.append(f"{wt.name}: unpushed commits on '{branch}'") + if repo is not None and branch != "?" and not integrated and has_unpushed_commits(wt): + problems.append(f"{wt.name}: unpushed commits on '{branch}'") if problems and not force: console.print( "[red]Refusing to remove workspace; found dirty or unpushed work:[/red]" @@ -968,12 +967,7 @@ def choose_files_for_wip(repo_path: Path, changes: List[Tuple[str, str]]) -> Lis return [] # iterfzf may return a single string or list depending on version; # normalize to list of strings. - if isinstance(selected, str): - selected_files = [selected] - else: - selected_files = list(selected) - - return selected_files + return [selected] if isinstance(selected, str) else list(selected) @app.command("wip") @@ -1480,9 +1474,8 @@ def create_if_needed_and_attach( return r.returncode == 0 # Inside tmux - if not session_exists(session_name): - if not create_detached_session(session_name, path_name, start_mode): - return False + if not session_exists(session_name) and not create_detached_session(session_name, path_name, start_mode): + return False r = run_tmux(["switch-client", "-t", session_name]) return r.returncode == 0 @@ -1618,12 +1611,11 @@ def tmux_cli_remove( tmux_sessions = [ session for session in get_tmux_sessions() if session.startswith("ω") ] - if not dry_run: - if not Confirm.ask( + if not dry_run and not Confirm.ask( f"Are you sure you want to remove all tmux sessions?\n* {'\n* '.join(tmux_sessions)}\n", default=False, ): - raise typer.Exit(1) + raise typer.Exit(1) if dry_run: console.print(tmux_sessions)