feat(worktree): add start point option for new branch creation

Allow selecting a base branch when creating new worktree branches
Add dropdown to choose start point from existing branches
Extend worktree creation flow to support custom branch origins
This commit is contained in:
Bohdan Triapitsyn
2026-01-01 13:39:55 +02:00
parent 39b9f985ce
commit 5a71e050a5
8 changed files with 326 additions and 48 deletions
+2 -2
View File
@@ -3400,12 +3400,12 @@ async function main(options = {}) {
return res.status(400).json({ error: 'directory parameter is required' });
}
const { path, branch, createBranch } = req.body;
const { path, branch, createBranch, startPoint } = req.body;
if (!path || !branch) {
return res.status(400).json({ error: 'path and branch are required' });
}
const result = await addWorktree(directory, path, branch, { createBranch });
const result = await addWorktree(directory, path, branch, { createBranch, startPoint });
res.json(result);
} catch (error) {
console.error('Failed to add worktree:', error);
+3
View File
@@ -830,6 +830,7 @@ export async function addWorktree(directory, worktreePath, branch, options = {})
try {
const args = ['worktree', 'add'];
const startPoint = typeof options.startPoint === 'string' ? options.startPoint.trim() : '';
if (options.createBranch) {
args.push('-b', branch);
@@ -839,6 +840,8 @@ export async function addWorktree(directory, worktreePath, branch, options = {})
if (!options.createBranch) {
args.push(branch);
} else if (startPoint) {
args.push(startPoint);
}
await git.raw(args);