Skip to content

feat(sync): fetch remote branch before creating worktree when it exists on origin#26

Merged
EndersonPro merged 2 commits intomainfrom
fix-sync-packages-from-origin
Apr 5, 2026
Merged

feat(sync): fetch remote branch before creating worktree when it exists on origin#26
EndersonPro merged 2 commits intomainfrom
fix-sync-packages-from-origin

Conversation

@EndersonPro
Copy link
Copy Markdown
Owner

Closes #24

Summary

  • When SyncWithRemote is enabled and the target branch doesn't exist locally but does exist on origin, fetch it and create the worktree from the remote tracking branch
  • This applies to both root and package repositories, ensuring consistent branch synchronization across all repos in the worktree
  • Add RemoteBranchExists method to GitPort interface and Gateway implementation

Changes

File Change
internal/app/ports.go Add RemoteBranchExists to GitPort interface
internal/infra/git/git.go Implement RemoteBranchExists with fetch + rev-parse check
internal/app/create_service.go Add remote branch check in createPlannedWorktree() before creating new branch
internal/app/create_service_test.go Add test for sync with remote branch existing on origin
internal/infra/git/git_test.go Add test for RemoteBranchExists
internal/app/add_repo_service_test.go Update mock to include new interface method
internal/app/services_test.go Update mock to include new interface method

Test Plan

  • All 141 tests pass across 11 packages (4 new tests added)
  • Build succeeds without errors
  • No breaking changes to existing sync behavior
  • Existing branches still sync correctly (unchanged path)
  • New branches from base still work when no remote branch exists

…ts on origin

When SyncWithRemote is enabled and the target branch doesn't exist locally
but does exist on origin, fetch it and create the worktree from the remote
tracking branch instead of creating a new branch from the base branch.

This applies to both root and package repositories.
@EndersonPro EndersonPro added enhancement New feature or request labels Apr 4, 2026
@EndersonPro EndersonPro merged commit f048287 into main Apr 5, 2026
2 checks passed
@EndersonPro EndersonPro deleted the fix-sync-packages-from-origin branch April 5, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sync): sync package branches from origin when they exist remotely

1 participant