From e18a8a8db493b9e9f4f1b4f987399fbf2a976d55 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 25 Nov 2025 20:55:23 -0600 Subject: [PATCH] roll back unpushed commits change --- workspaces.py | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/workspaces.py b/workspaces.py index 2937104..99b88ab 100755 --- a/workspaces.py +++ b/workspaces.py @@ -644,40 +644,31 @@ def find_repo_for_worktree( def has_unpushed_commits(repo_path: Path, branch: str) -> bool: """ - Detect if `branch` has commits not on its upstream. - - If no upstream is configured, we *do not* treat that as "unpushed" anymore, - just "can't check", and return False (so rm won't block on it). + Detect if branch has commits not on its upstream. + Uses 'git rev-list @{u}..HEAD'; if non-empty, there are unpushed commits. """ - # Find upstream ref, e.g. origin/branch - code, out, _ = run_cmd( + # Check if upstream exists + code, _, _ = run_cmd( ["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"], cwd=repo_path, ) if code != 0: - # No upstream configured; assume "not able to check", *not* a blocker. - return False + # No upstream configured; treat as unpushed work. + return True - upstream = out.strip() - if not upstream or upstream == "@{u}": - return False - - # Number of commits on HEAD that are not in upstream code, out, _ = run_cmd( - ["git", "rev-list", "--count", f"{upstream}..{branch}"], + ["git", "rev-list", "@{u}..HEAD", "--count"], cwd=repo_path, ) if code != 0: - # If we can't check, don't block - return False - + return True try: count = int(out.strip() or "0") except ValueError: - return False - + return True return count > 0 + def is_branch_integrated_into_main( repo_path: Path, branch: str,