feat/workspace-tmux-remove #3

Merged
waylon merged 9 commits from feat/workspace-tmux-remove into main 2025-11-26 12:46:09 -06:00
2 changed files with 9 additions and 17 deletions
Showing only changes of commit f51701818a - Show all commits

View file

@ -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

View file

@ -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)