-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Description
syncWorktree() in src/lib/worktree.ts determines the sync target by first checking HEAD@{upstream}, falling back to origin/main. This has two problems:
-
Syncs against origin, not local main. If you merge job A locally via
mc_mergebut haven't pushed,mc_syncon job B won't see job A's changes. The sequential merge workflow for standalone jobs requires pushing to origin between each merge. -
Can sync against the job's own tracking branch. If the job branch has an upstream set (e.g. after
git push -u),HEAD@{upstream}resolves to the job's own remote branch — the sync effectively does nothing useful.
Expected Behavior
mc_sync should reliably sync against the project's base branch (main/master), with an option to target local vs origin:
- Default: sync against the local base branch (covers the common
mc_merge→mc_sync→mc_mergeworkflow) - Optional
source: 'origin'flag for syncing against the remote
Current Behavior
// src/lib/worktree.ts — syncWorktree()
const upstreamResult = await gitCommand(
['-C', path, 'rev-parse', '--abbrev-ref', 'HEAD@{upstream}'],
);
// Falls back to origin/main if no upstream setThis logic should use getDefaultBranch() from src/lib/git.ts to determine the base branch, then target either the local ref or origin/<base>.
Proposed Fix
- Use
getDefaultBranch()to determine base branch name - Add
source: 'local' | 'origin'parameter (default'local') - Target
<baseBranch>for local,origin/<baseBranch>for origin - Update
src/tools/sync.tsto expose the new parameter
Files
src/lib/worktree.ts—syncWorktree()src/tools/sync.ts— tool definitionsrc/lib/git.ts— reusegetDefaultBranch()