feat: Validate default branch exists in repo when setting project defaultBranch
registerProject and updateProject now verify via remoteBranchExists that the specified branch actually exists in the cloned repository before saving.
This commit is contained in:
@@ -31,6 +31,21 @@ Worktrees stored in `.cw-worktrees/` subdirectory of the repo. Each agent gets a
|
||||
4. On conflict: `git merge --abort`, emit `worktree:conflict` with conflicting file list
|
||||
5. Restore original branch
|
||||
|
||||
### BranchManager (`src/git/branch-manager.ts`)
|
||||
- **Port**: `BranchManager` interface
|
||||
- **Adapter**: `SimpleGitBranchManager` using simple-git
|
||||
|
||||
| Method | Purpose |
|
||||
|--------|---------|
|
||||
| `ensureBranch(repoPath, branch, baseBranch)` | Create branch from base if it doesn't exist (idempotent) |
|
||||
| `mergeBranch(repoPath, source, target)` | Merge via ephemeral worktree, returns conflict info |
|
||||
| `diffBranches(repoPath, base, head)` | Three-dot diff between branches |
|
||||
| `deleteBranch(repoPath, branch)` | Delete local branch (no-op if missing) |
|
||||
| `branchExists(repoPath, branch)` | Check local branches |
|
||||
| `remoteBranchExists(repoPath, branch)` | Check remote tracking branches (`origin/<branch>`) |
|
||||
|
||||
`remoteBranchExists` is used by `registerProject` and `updateProject` to validate that a project's default branch actually exists in the cloned repository before saving.
|
||||
|
||||
### Project Clones
|
||||
- `cloneProject(url, destPath)` — Simple git clone wrapper
|
||||
- `ensureProjectClone(project, workspaceRoot)` — Idempotent: checks if clone exists, clones if not
|
||||
|
||||
Reference in New Issue
Block a user