From 8feb27d44cf842bc8bf11a79c73e403b240e5122 Mon Sep 17 00:00:00 2001 From: furiosa Date: Fri, 2 Jan 2026 17:11:11 -0800 Subject: [PATCH] fix(nuke): Check content on main, not just commit SHAs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After squash merge, polecat branches have different commit SHAs than main even though the content is identical. This was causing false "unpushed commits" warnings during nuke safety checks. Now uses `git diff` to verify if content differs from main, rather than just counting commits ahead. If diff is empty, content is on main (via squash merge) and nuke is safe. (gt-fo9iz) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/polecat.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/internal/cmd/polecat.go b/internal/cmd/polecat.go index a5862426..2ed8e66d 100644 --- a/internal/cmd/polecat.go +++ b/internal/cmd/polecat.go @@ -1041,12 +1041,16 @@ func getGitState(worktreePath string) (*GitState, error) { } // Check for unpushed commits (git log origin/main..HEAD) - logCmd := exec.Command("git", "log", "origin/main..HEAD", "--oneline") + // We check commits first, then verify if content differs. + // After squash merge, commits may differ but content may be identical. + mainRef := "origin/main" + logCmd := exec.Command("git", "log", mainRef+"..HEAD", "--oneline") logCmd.Dir = worktreePath output, err = logCmd.Output() if err != nil { // origin/main might not exist - try origin/master - logCmd = exec.Command("git", "log", "origin/master..HEAD", "--oneline") + mainRef = "origin/master" + logCmd = exec.Command("git", "log", mainRef+"..HEAD", "--oneline") logCmd.Dir = worktreePath output, _ = logCmd.Output() // non-fatal: might be a new repo without remote tracking } @@ -1058,9 +1062,22 @@ func getGitState(worktreePath string) (*GitState, error) { count++ } } - state.UnpushedCommits = count if count > 0 { - state.Clean = false + // Commits exist that aren't on main. But after squash merge, + // the content may actually be on main with different commit SHAs. + // Check if there's any actual diff between HEAD and main. + diffCmd := exec.Command("git", "diff", mainRef, "HEAD", "--quiet") + diffCmd.Dir = worktreePath + diffErr := diffCmd.Run() + if diffErr == nil { + // Exit code 0 means no diff - content IS on main (squash merged) + // Don't count these as unpushed + state.UnpushedCommits = 0 + } else { + // Exit code 1 means there's a diff - truly unpushed work + state.UnpushedCommits = count + state.Clean = false + } } }