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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user