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
|
||||
|
||||
@@ -140,10 +140,10 @@ Each procedure uses `require*Repository(ctx)` helpers that throw `TRPCError(INTE
|
||||
### Projects
|
||||
| Procedure | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| registerProject | mutation | Clone git repo, create record |
|
||||
| registerProject | mutation | Clone git repo, create record. Validates defaultBranch exists in repo |
|
||||
| listProjects | query | All projects |
|
||||
| getProject | query | Single project |
|
||||
| updateProject | mutation | Update project settings (defaultBranch) |
|
||||
| updateProject | mutation | Update project settings (defaultBranch). Validates branch exists in repo |
|
||||
| deleteProject | mutation | Delete clone and record |
|
||||
| getInitiativeProjects | query | Projects for initiative |
|
||||
| updateInitiativeProjects | mutation | Sync junction table |
|
||||
|
||||
Reference in New Issue
Block a user