fix(update): sync default branch from the configured upstream on both paths - #30
Merged
Conversation
epodivilov
marked this pull request as ready for review
July 21, 2026 22:04
… paths When the default branch had no worktree, `wt update` updated its ref from the primary remote and skipped post-update hooks, while the worktree path fast-forwarded from the configured upstream and ran them. In a fork workflow the base of every subsequent rebase therefore depended on whether the default branch happened to be checked out. - updateBranchRef takes an optional remote, mirroring mergeFFOnly, and the use case passes the configured upstream on both paths - post-update hooks for the default branch run on both paths; with no worktree for it they run in the repository root - primary-remote resolution leaves the adapter's per-instance cache: it is exposed as resolvePrimaryRemote, resolved once in the container, and injected
epodivilov
force-pushed
the
fix/unify-remote-resolution
branch
from
July 21, 2026 22:08
29725ff to
35261a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
wt updatedecides how to advance the default branch based on whether it has a worktree: fast-forward when it does, ref update when it doesn't. Those two paths disagreed on everything else.upstream; the ref-update path always used the primary remote and ignoredupstream. In a fork workflow that silently changed the base of every subsequent rebase depending on whether the default branch happened to be checked out.updateBranchRefnow takes an optional remote, mirroringmergeFFOnly, and the use case passes the configured upstream on both paths.post-updatehooks ran for the default branch only on the fast-forward path. They now run on both after a successful upstream sync; with no worktree for the default branch they run in the repository root, and their results are reported the same way.Why the adapter refactor is here
Primary-remote resolution used to be memoized in a closure inside the git adapter that never invalidated, so tests had to build a fresh adapter per case to avoid a stale value. It is now
resolvePrimaryRemote, resolved once in the container and injected into the adapter. That removes the mutable state, makes the remote a composition-time decision, and is what makes the behavior above testable without the fresh-adapter workaround.What a user notices
With
upstreamconfigured and no worktree for the default branch:<upstream>/<default>instead oforigin/<default>post-updatehooks run for it (for example, pushing the synced default branch back to the fork)<default> synced from <upstream>/<default>instead of<default> ref updatedWithout
upstreamconfigured, behavior is unchanged.Checks
pnpm typecheck,pnpm lint,pnpm test— 523 tests pass. New coverage for the no-worktree path with an explicit upstream (remote choice, hooks, dry run) and forresolvePrimaryRemote(default-branch tracking remote, current-branch fallback, sole remote,.sentinel, no-remote fallback toorigin). Both fixes were mutation-checked: reverting either one fails the new tests.