wip: feat: workspace tmux remove

This commit is contained in:
Waylon Walker 2025-11-26 10:58:19 -06:00
parent 7b1a33414a
commit f51701818a
2 changed files with 9 additions and 17 deletions

View file

@ -75,10 +75,10 @@ select = [
"RSE", # flake8-raise "RSE", # flake8-raise
"RET", # flake8-return "RET", # flake8-return
# "SLF", # flake8-self # "SLF", # flake8-self
# "SIM", # flake8-simplify "SIM", # flake8-simplify
"TID", # flake8-tidy-imports "TID", # flake8-tidy-imports
"TCH", # flake8-type-checking "TCH", # flake8-type-checking
# "INT", # flake8-gettext "INT", # flake8-gettext
"ARG", # flake8-unused-arguments "ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib "PTH", # flake8-use-pathlib
"ERA", # eradicate "ERA", # eradicate

View file

@ -838,9 +838,8 @@ def remove_workspace(
problems.append(f"{wt.name}: dirty working tree on '{branch}'") problems.append(f"{wt.name}: dirty working tree on '{branch}'")
# Only care about "unpushed commits" if the branch is NOT integrated into main. # Only care about "unpushed commits" if the branch is NOT integrated into main.
if repo is not None and branch != "?" and not integrated: if repo is not None and branch != "?" and not integrated and has_unpushed_commits(wt):
if has_unpushed_commits(wt): problems.append(f"{wt.name}: unpushed commits on '{branch}'")
problems.append(f"{wt.name}: unpushed commits on '{branch}'")
if problems and not force: if problems and not force:
console.print( console.print(
"[red]Refusing to remove workspace; found dirty or unpushed work:[/red]" "[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 [] return []
# iterfzf may return a single string or list depending on version; # iterfzf may return a single string or list depending on version;
# normalize to list of strings. # normalize to list of strings.
if isinstance(selected, str): return [selected] if isinstance(selected, str) else list(selected)
selected_files = [selected]
else:
selected_files = list(selected)
return selected_files
@app.command("wip") @app.command("wip")
@ -1480,9 +1474,8 @@ def create_if_needed_and_attach(
return r.returncode == 0 return r.returncode == 0
# Inside tmux # Inside tmux
if not session_exists(session_name): if not session_exists(session_name) and not create_detached_session(session_name, path_name, start_mode):
if not create_detached_session(session_name, path_name, start_mode): return False
return False
r = run_tmux(["switch-client", "-t", session_name]) r = run_tmux(["switch-client", "-t", session_name])
return r.returncode == 0 return r.returncode == 0
@ -1618,12 +1611,11 @@ def tmux_cli_remove(
tmux_sessions = [ tmux_sessions = [
session for session in get_tmux_sessions() if session.startswith("ω") session for session in get_tmux_sessions() if session.startswith("ω")
] ]
if not dry_run: if not dry_run and not Confirm.ask(
if not Confirm.ask(
f"Are you sure you want to remove all tmux sessions?\n* {'\n* '.join(tmux_sessions)}\n", f"Are you sure you want to remove all tmux sessions?\n* {'\n* '.join(tmux_sessions)}\n",
default=False, default=False,
): ):
raise typer.Exit(1) raise typer.Exit(1)
if dry_run: if dry_run:
console.print(tmux_sessions) console.print(tmux_sessions)