PR #7 review: count 'ahead' against HEAD, not local main
The ticker note says the branch point is N ahead of this checkout, but the count compared origin/main to the local main branch — misleading whenever the board runs from another branch or detached HEAD. HEAD is the fallback base, so HEAD..origin/main is exactly what launching from it would have missed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -168,7 +168,10 @@ def _fresh_branch_point() -> tuple[str | None, str | None]:
|
||||
if fetched.returncode != 0 or \
|
||||
_git("rev-parse", "--verify", "--quiet", "origin/main").returncode != 0:
|
||||
return None, "fetch of origin/main failed; branched from local HEAD"
|
||||
ahead = _git("rev-list", "--count", "main..origin/main").stdout.strip()
|
||||
# Counted against HEAD, not main: HEAD is the fallback base, so this is
|
||||
# exactly what launching would have missed — accurate even when the
|
||||
# board checkout sits on another branch.
|
||||
ahead = _git("rev-list", "--count", "HEAD..origin/main").stdout.strip()
|
||||
if ahead.isdigit() and int(ahead) > 0:
|
||||
return "origin/main", (f"branched from origin/main, "
|
||||
f"{ahead} ahead of this checkout")
|
||||
|
||||
@@ -98,6 +98,15 @@ class FreshBranchPoint(unittest.TestCase):
|
||||
capture_output=True)
|
||||
self.assertNotEqual(upstream_cfg.returncode, 0)
|
||||
|
||||
def test_ahead_count_is_relative_to_the_checkout_not_local_main(self):
|
||||
# The checkout already holds origin/main's tip on another branch;
|
||||
# only local main is behind. Nothing was missed, so no narration —
|
||||
# counting main..origin/main would have claimed "1 ahead" here.
|
||||
_commit(self.upstream, "landed elsewhere")
|
||||
_git(self.local, "fetch", "-q", "origin")
|
||||
_git(self.local, "checkout", "-q", "-b", "other", "origin/main")
|
||||
self.assertEqual(agents._fresh_branch_point(), ("origin/main", None))
|
||||
|
||||
def test_origin_in_sync_is_used_without_narration(self):
|
||||
self.assertEqual(agents._fresh_branch_point(), ("origin/main", None))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user