prune, ignore 0 updates
This commit is contained in:
parent
04b07c3ef4
commit
9ceb1915e1
1 changed files with 25 additions and 1 deletions
|
|
@ -1373,9 +1373,14 @@ def clean_workspace(
|
||||||
f"Cleaning workspace [bold]{title or ws_dir.name}[/bold] (dir: {repo.name})"
|
f"Cleaning workspace [bold]{title or ws_dir.name}[/bold] (dir: {repo.name})"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
run_cmd(["git", "fetch", "--all", "--prune"], cwd=repo)
|
||||||
local_branches_merged = get_branches_merged(repo, remote=False)
|
local_branches_merged = get_branches_merged(repo, remote=False)
|
||||||
remote_branches_merged = get_branches_merged(repo, remote=True)
|
remote_branches_merged = get_branches_merged(repo, remote=True)
|
||||||
|
|
||||||
|
if len(local_branches_merged) == 0 and len(remote_branches_merged) == 0:
|
||||||
|
console.print("[green]No branches to delete.[/green]")
|
||||||
|
raise typer.Exit(0)
|
||||||
|
|
||||||
console.print(
|
console.print(
|
||||||
f"[green]Would delete {len(local_branches_merged)} local branches[/green]"
|
f"[green]Would delete {len(local_branches_merged)} local branches[/green]"
|
||||||
)
|
)
|
||||||
|
|
@ -1401,7 +1406,26 @@ def clean_workspace(
|
||||||
run_cmd(cmd, cwd=repo)
|
run_cmd(cmd, cwd=repo)
|
||||||
|
|
||||||
for b in remote_branches_merged:
|
for b in remote_branches_merged:
|
||||||
cmd = ["git", "push", "origin", "--delete", b]
|
# b looks like "origin/feat/workspaces-tmux-support"
|
||||||
|
if "->" in b:
|
||||||
|
# safety: skip symbolic refs like "origin/HEAD -> origin/main"
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
remote, branch = b.split("/", 1)
|
||||||
|
except ValueError:
|
||||||
|
# fallback: no slash? assume origin + raw name
|
||||||
|
remote, branch = "origin", b
|
||||||
|
|
||||||
|
cmd = ["git", "push", remote, "--delete", branch]
|
||||||
|
|
||||||
|
status, out, err = run_cmd(cmd, cwd=repo)
|
||||||
|
|
||||||
|
if status != 0:
|
||||||
|
console.print(f"[red]Failed to delete {remote}/{branch}:[/red]\n{err}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
console.print("[green]Done.[/green]")
|
||||||
|
|
||||||
|
|
||||||
def in_tmux() -> bool:
|
def in_tmux() -> bool:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue