fix(worktrees): default to HEAD when no startPoint provided
- Use git reset --hard HEAD by default when startPoint is not provided or is HEAD - Preserve resetting to the provided startPoint when a concrete value is supplied
This commit is contained in:
@@ -99,6 +99,7 @@ export async function createWorktreeSession(): Promise<{ id: string } | null> {
|
||||
const createdMetadata = {
|
||||
...metadata,
|
||||
createdFromBranch: startPoint ?? 'HEAD',
|
||||
kind: 'standard' as const,
|
||||
};
|
||||
|
||||
// Get worktree status
|
||||
@@ -271,6 +272,7 @@ export async function createWorktreeSessionForBranch(
|
||||
const createdMetadata = {
|
||||
...metadata,
|
||||
createdFromBranch: branchName,
|
||||
kind: 'standard' as const,
|
||||
};
|
||||
|
||||
// Get worktree status
|
||||
@@ -394,7 +396,7 @@ export async function createWorktreeSessionForNewBranch(
|
||||
projectDirectory: string,
|
||||
preferredBranchName: string,
|
||||
startPoint: string,
|
||||
options?: { allowSuffix?: boolean }
|
||||
options?: { allowSuffix?: boolean; kind?: 'pr' | 'standard' }
|
||||
): Promise<{ id: string; branch: string } | null> {
|
||||
if (isCreatingWorktreeSession) {
|
||||
return null;
|
||||
@@ -425,6 +427,7 @@ export async function createWorktreeSessionForNewBranch(
|
||||
}
|
||||
|
||||
const allowSuffix = options?.allowSuffix !== false;
|
||||
const kind = options?.kind ?? 'standard';
|
||||
|
||||
const projectRef = resolveProjectRef(projectDirectory);
|
||||
if (!projectRef) {
|
||||
@@ -444,6 +447,7 @@ export async function createWorktreeSessionForNewBranch(
|
||||
const createdMetadata = {
|
||||
...metadata,
|
||||
createdFromBranch: start,
|
||||
kind,
|
||||
};
|
||||
|
||||
const status = await getWorktreeStatus(metadata.path).catch(() => undefined);
|
||||
@@ -543,7 +547,11 @@ export async function createWorktreeSessionForNewBranch(
|
||||
export async function createWorktreeSessionForNewBranchExact(
|
||||
projectDirectory: string,
|
||||
branchName: string,
|
||||
startPoint: string
|
||||
startPoint: string,
|
||||
options?: { kind?: 'pr' | 'standard' }
|
||||
): Promise<{ id: string; branch: string } | null> {
|
||||
return createWorktreeSessionForNewBranch(projectDirectory, branchName, startPoint, { allowSuffix: false });
|
||||
return createWorktreeSessionForNewBranch(projectDirectory, branchName, startPoint, {
|
||||
allowSuffix: false,
|
||||
kind: options?.kind,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ export const buildSdkStartCommand = (args: {
|
||||
const startPoint = typeof args.startPoint === 'string' ? args.startPoint.trim() : '';
|
||||
if (startPoint && startPoint !== 'HEAD') {
|
||||
commands.push(`git reset --hard ${shellQuote(startPoint)}`);
|
||||
} else {
|
||||
commands.push('git reset --hard HEAD');
|
||||
}
|
||||
|
||||
for (const raw of args.setupCommands) {
|
||||
|
||||
Reference in New Issue
Block a user