fix: capture_diff uses base commit to handle agent self-commits
Claude in agentic mode (interactive, no -p flag) commits its own changes, advancing HEAD. This made `git diff --cached HEAD` return empty, triggering false EMPTY_DIFF errors every time. Now capture_diff diffs against the base commit SHA recorded at worktree creation, so changes are captured regardless of whether the agent committed them. Also adds UX_IMPROVEMENT_PLAN.md for guided message improvements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -775,11 +775,18 @@ class TestRuntimeEnvironmentHelpers(unittest.TestCase):
|
||||
class TestWorktreeFailures(unittest.TestCase):
|
||||
@patch("cross_eval.worktree.subprocess.run")
|
||||
def test_create_worktree_raises_when_branch_creation_fails(self, mock_run: MagicMock) -> None:
|
||||
mock_run.side_effect = subprocess.CalledProcessError(
|
||||
1,
|
||||
["git", "branch"],
|
||||
stderr="branch failed",
|
||||
)
|
||||
# First call: git rev-parse HEAD (succeeds)
|
||||
# Second call: git branch (fails)
|
||||
rev_parse_result = MagicMock(returncode=0)
|
||||
rev_parse_result.stdout = "a" * 40
|
||||
mock_run.side_effect = [
|
||||
rev_parse_result,
|
||||
subprocess.CalledProcessError(
|
||||
1,
|
||||
["git", "branch"],
|
||||
stderr="branch failed",
|
||||
),
|
||||
]
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
base = Path(tmpdir)
|
||||
@@ -791,14 +798,17 @@ class TestWorktreeFailures(unittest.TestCase):
|
||||
|
||||
@patch("cross_eval.worktree.subprocess.run")
|
||||
def test_create_worktree_cleans_branch_on_worktree_failure(self, mock_run: MagicMock) -> None:
|
||||
rev_parse_result = MagicMock(returncode=0)
|
||||
rev_parse_result.stdout = "a" * 40
|
||||
mock_run.side_effect = [
|
||||
MagicMock(returncode=0),
|
||||
rev_parse_result, # git rev-parse HEAD
|
||||
MagicMock(returncode=0), # git branch
|
||||
subprocess.CalledProcessError(
|
||||
1,
|
||||
["git", "worktree", "add"],
|
||||
stderr="worktree failed",
|
||||
),
|
||||
MagicMock(returncode=0),
|
||||
MagicMock(returncode=0), # git branch -D (cleanup)
|
||||
]
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
||||
Reference in New Issue
Block a user