Skip to content

Commit 77a573b

Browse files
Fixes interactive rebase being incorrectly gated for some targets
1 parent 30e5ebc commit 77a573b

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/commands/git/rebase.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class RebaseGitCommand extends QuickCommand<State> {
226226
const title = `${context.title} ${getReferenceLabel(state.destination, { icon: false, label: false })}`;
227227
const ahead = counts != null ? counts.right : 0;
228228
const behind = counts != null ? counts.left : 0;
229-
if (behind === 0) {
229+
if (behind === 0 && ahead === 0) {
230230
const step: QuickPickStep<DirectiveQuickPickItem> = this.createConfirmStep(
231231
appendReposToTitle(title, state, context),
232232
[],
@@ -248,9 +248,20 @@ export class RebaseGitCommand extends QuickCommand<State> {
248248
return StepResultBreak;
249249
}
250250

251-
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
252-
appendReposToTitle(`Confirm ${title}`, state, context),
253-
[
251+
const rebaseItems = [
252+
createFlagsQuickPickItem<Flags>(state.flags, ['--interactive'], {
253+
label: `Interactive ${this.title}`,
254+
description: '--interactive',
255+
detail: `Will interactively update ${getReferenceLabel(context.branch, {
256+
label: false,
257+
})} by applying ${pluralize('commit', ahead)} on top of ${getReferenceLabel(state.destination, {
258+
label: false,
259+
})}`,
260+
}),
261+
];
262+
263+
if (behind > 0) {
264+
rebaseItems.unshift(
254265
createFlagsQuickPickItem<Flags>(state.flags, [], {
255266
label: this.title,
256267
detail: `Will update ${getReferenceLabel(context.branch, {
@@ -259,16 +270,12 @@ export class RebaseGitCommand extends QuickCommand<State> {
259270
label: false,
260271
})}`,
261272
}),
262-
createFlagsQuickPickItem<Flags>(state.flags, ['--interactive'], {
263-
label: `Interactive ${this.title}`,
264-
description: '--interactive',
265-
detail: `Will interactively update ${getReferenceLabel(context.branch, {
266-
label: false,
267-
})} by applying ${pluralize('commit', ahead)} on top of ${getReferenceLabel(state.destination, {
268-
label: false,
269-
})}`,
270-
}),
271-
],
273+
);
274+
}
275+
276+
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
277+
appendReposToTitle(`Confirm ${title}`, state, context),
278+
rebaseItems,
272279
);
273280
const selection: StepSelection<typeof step> = yield step;
274281
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;

0 commit comments

Comments
 (0)