Ver a proveniência

Closes #1269 - splits revert and revert + edit

main
Eric Amodio há 4 anos
ascendente
cometimento
a8432e54df
2 ficheiros alterados com 25 adições e 12 eliminações
  1. +2
    -1
      CHANGELOG.md
  2. +23
    -11
      src/commands/git/revert.ts

+ 2
- 1
CHANGELOG.md Ver ficheiro

@ -24,7 +24,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Changed
- Increases the thickness (boldness) of a handful of icons to better match VS Code codicons
- Changes the options on the _Git Command Palette_'s _revert_ command to now be _Revert_ (`--no-edit`) and _Revert & Edit_ (`--edit`) — closes [#1269](https://github.com/eamodio/vscode-gitlens/issues/1269)
- Changes the thickness (boldness) of a handful of icons to better match VS Code codicons
### Fixed

+ 23
- 11
src/commands/git/revert.ts Ver ficheiro

@ -1,5 +1,4 @@
'use strict';
import { QuickPickItem } from 'vscode';
import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevisionReference, Repository } from '../../git/git';
import {
@ -15,6 +14,7 @@ import {
StepSelection,
StepState,
} from '../quickCommand';
import { FlagsQuickPickItem } from '../../quickpicks';
interface Context {
repos: Repository[];
@ -23,9 +23,12 @@ interface Context {
title: string;
}
type Flags = '--edit' | '--no-edit';
interface State<Refs = GitRevisionReference | GitRevisionReference[]> {
repo: string | Repository;
references: Refs;
flags: Flags[];
}
export interface RevertGitCommandArgs {
@ -65,7 +68,7 @@ export class RevertGitCommand extends QuickCommand {
}
execute(state: RevertStepState<State<GitRevisionReference[]>>) {
return state.repo.revert(...state.references.map(c => c.ref).reverse());
return state.repo.revert(...state.flags, ...state.references.map(c => c.ref).reverse());
}
protected async *steps(state: PartialStepState<State>): StepGenerator {
@ -76,6 +79,10 @@ export class RevertGitCommand extends QuickCommand {
title: this.title,
};
if (state.flags == null) {
state.flags = [];
}
if (state.references != null && !Array.isArray(state.references)) {
state.references = [state.references];
}
@ -142,9 +149,11 @@ export class RevertGitCommand extends QuickCommand {
state.references = result;
}
const result = yield* this.confirmStep(state as RevertStepState<State<GitRevisionReference[]>>, context);
const result = yield* this.confirmStep(state as RevertStepState, context);
if (result === StepResult.Break) continue;
state.flags = result;
QuickCommand.endSteps(state);
this.execute(state as RevertStepState<State<GitRevisionReference[]>>);
}
@ -152,20 +161,23 @@ export class RevertGitCommand extends QuickCommand {
return state.counter < 0 ? StepResult.Break : undefined;
}
private *confirmStep(
state: RevertStepState<State<GitRevisionReference[]>>,
context: Context,
): StepResultGenerator<void> {
const step: QuickPickStep<QuickPickItem> = this.createConfirmStep(
private *confirmStep(state: RevertStepState, context: Context): StepResultGenerator<Flags[]> {
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
{
FlagsQuickPickItem.create<Flags>(state.flags, ['--no-edit'], {
label: this.title,
description: '--no-edit',
detail: `Will revert ${GitReference.toString(state.references)}`,
},
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--edit'], {
label: `${this.title} & Edit`,
description: '--edit',
detail: `Will revert and edit ${GitReference.toString(state.references)}`,
}),
],
);
const selection: StepSelection<typeof step> = yield step;
return QuickCommand.canPickStepContinue(step, state, selection) ? undefined : StepResult.Break;
return QuickCommand.canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
}
}

Carregando…
Cancelar
Guardar