diff --git a/cross_eval/pipeline.py b/cross_eval/pipeline.py index b6e5441..9f2caa3 100644 --- a/cross_eval/pipeline.py +++ b/cross_eval/pipeline.py @@ -263,8 +263,6 @@ def _finalize_worktree( ) if committed: logger.info(" Agentic changes committed on branch: %s", branch_name) - else: - logger.warning(" No agentic changes to commit (empty diff)") except Exception: logger.warning(" Failed to commit agentic changes", exc_info=True) @@ -273,25 +271,36 @@ def _finalize_worktree( except Exception: logger.warning("Failed to clean up worktree: %s", worktree_path) - # Check if branch has any commits beyond the base — if not, delete it - if not committed: - try: - # Check if branch has diverged from its base - result = subprocess.run( - ["git", "log", "--oneline", f"HEAD..{branch_name}"], - cwd=cwd, capture_output=True, text=True, - ) - if not result.stdout.strip(): - # No commits on branch beyond base — clean up - subprocess.run( - ["git", "branch", "-D", branch_name], - cwd=cwd, capture_output=True, - ) - logger.info(" Deleted empty branch: %s", branch_name) - except Exception: - pass # best-effort cleanup + # Check if branch has any commits beyond the base (including intermediate + # commits from _commit_iteration, not just the final commit). + has_branch_commits = False + try: + result = subprocess.run( + ["git", "log", "--oneline", f"HEAD..{branch_name}"], + cwd=cwd, capture_output=True, text=True, + ) + has_branch_commits = bool(result.stdout.strip()) + except Exception: + pass - return branch_name if committed else None + if has_branch_commits: + if not committed: + logger.info(" Agentic changes on branch: %s (from intermediate commits)", branch_name) + return branch_name + + # No commits on branch at all — clean up + try: + subprocess.run( + ["git", "branch", "-D", branch_name], + cwd=cwd, capture_output=True, + ) + logger.info(" Deleted empty branch: %s", branch_name) + except Exception: + pass # best-effort cleanup + + if not committed: + logger.warning(" No agentic changes to commit (empty diff)") + return None def _run_simple_pipeline( diff --git a/tests/test_config.py b/tests/test_config.py index 2e5828a..787d9e5 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -71,8 +71,11 @@ class BuiltinAgentConfigTest(unittest.TestCase): self.assertIn("--dangerously-skip-permissions", coder_args) self.assertIn("bypassPermissions", coder_args) - self.assertIn("plan", reviewer_args) - self.assertIn("plan", senior_args) + # Reviewers/seniors use -p without --permission-mode plan + self.assertIn("-p", reviewer_args) + self.assertIn("-p", senior_args) + self.assertNotIn("plan", reviewer_args) + self.assertNotIn("plan", senior_args) def test_codex_builtin_agents_skip_git_repo_check(self) -> None: for agent_name in ("codex-coder", "codex-reviewer", "codex-senior"):