Answer stability round 2: 0 🔴, 1 🟡 (0 misread); ask origin for the epic branch before the fetch, so a branch another chunk makes in between doesn't fail the start

This commit is contained in:
2026-11-20 23:35:07 +01:00
parent e37dafb753
commit 071a350e2b
2 changed files with 24 additions and 9 deletions
+5 -3
View File
@@ -9,9 +9,11 @@ def levelled(branch: str, default: str, cwd: str | None = None, timeout: float |
"""Brings origin's branch level with default, the default branch's ref, such as `origin/main`, and fetches it: what it did, as a sentence. Where origin has no such branch, it makes one at default.
A call to origin still running after timeout seconds fails. again is False in the second try `merged` makes after a push that failed."""
held = fetched(cwd, timeout, run) or on_origin(branch, cwd, timeout, run)
if isinstance(held, Failure):
return held
# Asked before the fetch: a branch another chunk makes after the fetch would be on origin and missing here.
held = on_origin(branch, cwd, timeout, run)
failed = held if isinstance(held, Failure) else fetched(cwd, timeout, run)
if isinstance(failed, Failure):
return failed
if not held:
return pushed(default, branch, cwd, timeout, run) or f"Made origin/{branch} off {default}."
return merged(branch, default, cwd, timeout, run, again)