Skip to content

Commit c761653

Browse files
committed
Selects if user wants to create a branch on a worktree or not
(#3621)
1 parent 2ae17d8 commit c761653

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/plus/startWork/startWork.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ interface Context {
5555
interface State {
5656
item?: StartWorkItem;
5757
action?: StartWorkAction;
58+
inWorktree?: boolean;
5859
}
5960

6061
type StartWorkStepState<T extends State = State> = RequireSome<StepState<T>, 'item'>;
@@ -136,6 +137,7 @@ export class StartWorkCommand extends QuickCommand<State> {
136137
const result = yield* this.selectCommandStep(state);
137138
if (result === StepResultBreak) continue;
138139
state.action = result.action;
140+
state.inWorktree = result.inWorktree;
139141

140142
await updateContextItems(this.container, context);
141143

@@ -172,7 +174,9 @@ export class StartWorkCommand extends QuickCommand<State> {
172174
name: issue ? slug(`${issue.id}-${issue.title}`) : undefined,
173175
suggestNameOnly: true,
174176
suggestRepoOnly: true,
177+
flags: state.inWorktree ? ['--worktree'] : [],
175178
},
179+
confirm: !state.inWorktree,
176180
},
177181
this.pickedVia,
178182
);
@@ -186,14 +190,18 @@ export class StartWorkCommand extends QuickCommand<State> {
186190
return state.counter < 0 ? StepResultBreak : undefined;
187191
}
188192

189-
private *selectCommandStep(state: StepState<State>): StepResultGenerator<{ action?: StartWorkAction }> {
193+
private *selectCommandStep(
194+
state: StepState<State>,
195+
): StepResultGenerator<{ action?: StartWorkAction; inWorktree?: boolean }> {
190196
const step = createPickStep({
191197
placeholder: 'Start work by creating a new branch',
192198
items: [
193199
createQuickPickItemOfT('Create a branch', {
194200
action: 'start',
195201
}),
202+
createQuickPickItemOfT('Create a branch on a worktree', { action: 'start', inWorktree: true }),
196203
createQuickPickItemOfT('Create a branch from an issue', {}),
204+
createQuickPickItemOfT('Create a branch from an issue on a worktree', { inWorktree: true }),
197205
],
198206
});
199207
const selection: StepSelection<typeof step> = yield step;

0 commit comments

Comments
 (0)