Browse Source

Reorgs git commands

Adds explicit directive for going back
Adds command error logging
Removes unneeded abort error
main
Eric Amodio 5 years ago
parent
commit
5c3f6b5b05
21 changed files with 1582 additions and 1559 deletions
  1. +5
    -11
      src/commands/git/checkout.ts
  2. +14
    -15
      src/commands/git/cherry-pick.ts
  3. +4
    -3
      src/commands/git/fetch.ts
  4. +11
    -17
      src/commands/git/merge.ts
  5. +4
    -3
      src/commands/git/pull.ts
  6. +4
    -3
      src/commands/git/push.ts
  7. +11
    -17
      src/commands/git/rebase.ts
  8. +36
    -22
      src/commands/gitCommands.ts
  9. +2
    -2
      src/commands/quickCommand.helpers.ts
  10. +27
    -25
      src/commands/quickCommand.ts
  11. +27
    -7
      src/quickpicks/gitQuickPicks.ts
  12. +6
    -3
      src/views/viewCommands.ts

src/commands/quick/checkout.ts → src/commands/git/checkout.ts View File

@ -4,16 +4,10 @@ import { ProgressLocation, QuickInputButtons, window } from 'vscode';
import { Container } from '../../container';
import { GitBranch, GitReference, GitTag, Repository } from '../../git/gitService';
import { GlyphChars } from '../../constants';
import {
CommandAbortError,
getBranchesAndOrTags,
QuickCommandBase,
QuickInputStep,
QuickPickStep,
StepState
} from './quickCommand';
import { getBranchesAndOrTags, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import { ReferencesQuickPickItem, RefQuickPickItem, RepositoryQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { Logger } from '../../logger';
interface State {
repos: Repository[];
@ -28,7 +22,7 @@ export interface CommandArgs {
skipConfirmation?: boolean;
}
export class CheckoutQuickCommand extends QuickCommandBase<State> {
export class CheckoutGitCommand extends QuickCommandBase<State> {
constructor(args?: CommandArgs) {
super('checkout', 'Checkout');
@ -211,7 +205,7 @@ export class CheckoutQuickCommand extends QuickCommandBase {
? state.repos[0].formattedName
: `${state.repos.length} repositories`
}`,
placeholder: 'Choose name for the local branch',
placeholder: 'Please provide a name for the local branch',
value: state.branchOrTagOrRef.getName(),
validate: async (value: string | undefined): Promise<[boolean, string | undefined]> => {
if (value == null) return [false, undefined];
@ -268,7 +262,7 @@ export class CheckoutQuickCommand extends QuickCommandBase {
break;
}
catch (ex) {
if (ex instanceof CommandAbortError) break;
Logger.error(ex, this.title);
throw ex;
}

src/commands/quick/cherry-pick.ts → src/commands/git/cherry-pick.ts View File

@ -4,17 +4,16 @@ import { Container } from '../../container';
import { GitBranch, GitLogCommit, GitReference, Repository } from '../../git/gitService';
import { GlyphChars } from '../../constants';
import { Iterables, Strings } from '../../system';
import { getBranchesAndOrTags, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import {
CommandAbortError,
getBranchesAndOrTags,
QuickCommandBase,
QuickInputStep,
QuickPickStep,
StepState
} from './quickCommand';
import { BranchQuickPickItem, CommitQuickPickItem, RepositoryQuickPickItem } from '../../quickpicks';
BackOrCancelQuickPickItem,
BranchQuickPickItem,
CommitQuickPickItem,
RefQuickPickItem,
RepositoryQuickPickItem
} from '../../quickpicks';
import { runGitCommandInTerminal } from '../../terminal';
import { RefQuickPickItem } from '../../quickpicks/gitQuickPicks';
import { Logger } from '../../logger';
interface State {
repo: Repository;
@ -23,7 +22,7 @@ interface State {
commits?: GitLogCommit[];
}
export class CherryPickQuickCommand extends QuickCommandBase<State> {
export class CherryPickGitCommand extends QuickCommandBase<State> {
constructor() {
super('cherry-pick', 'Cherry Pick', { description: 'via Terminal' });
}
@ -86,7 +85,7 @@ export class CherryPickQuickCommand extends QuickCommandBase {
const step = this.createPickStep<BranchQuickPickItem | RefQuickPickItem>({
title: `${this.title} into ${state.destination.name}${Strings.pad(GlyphChars.Dot, 2, 2)}${
state.repo.name
state.repo.formattedName
}`,
placeholder: `Choose a branch or tag to cherry-pick from${GlyphChars.Space.repeat(
3
@ -129,7 +128,7 @@ export class CherryPickQuickCommand extends QuickCommandBase {
const step = this.createPickStep<CommitQuickPickItem>({
title: `${this.title} onto ${state.destination.name}${Strings.pad(GlyphChars.Dot, 2, 2)}${
state.repo.name
state.repo.formattedName
}`,
multiselect: log !== undefined,
placeholder:
@ -138,7 +137,7 @@ export class CherryPickQuickCommand extends QuickCommandBase {
: `Choose commits to cherry-pick onto ${state.destination.name}`,
items:
log === undefined
? []
? [BackOrCancelQuickPickItem.create(false, true), BackOrCancelQuickPickItem.create()]
: [
...Iterables.map(log.commits.values(), commit =>
CommitQuickPickItem.create(
@ -159,7 +158,7 @@ export class CherryPickQuickCommand extends QuickCommandBase {
}
const step = this.createConfirmStep(
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.name}`,
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.formattedName}`,
[
state.commits !== undefined
? {
@ -192,7 +191,7 @@ export class CherryPickQuickCommand extends QuickCommandBase {
break;
}
catch (ex) {
if (ex instanceof CommandAbortError) break;
Logger.error(ex, this.title);
throw ex;
}

src/commands/quick/fetch.ts → src/commands/git/fetch.ts View File

@ -2,10 +2,11 @@
import { QuickPickItem } from 'vscode';
import { Container } from '../../container';
import { Repository } from '../../git/gitService';
import { CommandAbortError, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from './quickCommand';
import { QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import { RepositoryQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { GlyphChars } from '../../constants';
import { Logger } from '../../logger';
interface State {
repos: Repository[];
@ -19,7 +20,7 @@ export interface CommandArgs {
skipConfirmation?: boolean;
}
export class FetchQuickCommand extends QuickCommandBase<State> {
export class FetchGitCommand extends QuickCommandBase<State> {
constructor(args?: CommandArgs) {
super('fetch', 'Fetch');
@ -154,7 +155,7 @@ export class FetchQuickCommand extends QuickCommandBase {
break;
}
catch (ex) {
if (ex instanceof CommandAbortError) break;
Logger.error(ex, this.title);
throw ex;
}

src/commands/quick/merge.ts → src/commands/git/merge.ts View File

@ -1,28 +1,22 @@
'use strict';
import { QuickPickItem } from 'vscode';
import { Container } from '../../container';
import { GitBranch, Repository } from '../../git/gitService';
import { GitBranch, GitTag, Repository } from '../../git/gitService';
import { GlyphChars } from '../../constants';
import {
CommandAbortError,
getBranchesAndOrTags,
QuickCommandBase,
QuickInputStep,
QuickPickStep,
StepState
} from './quickCommand';
import { BranchQuickPickItem, RepositoryQuickPickItem } from '../../quickpicks';
import { getBranchesAndOrTags, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import { BranchQuickPickItem, RepositoryQuickPickItem, TagQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { runGitCommandInTerminal } from '../../terminal';
import { Logger } from '../../logger';
interface State {
repo: Repository;
destination: GitBranch;
source: GitBranch;
source: GitBranch | GitTag;
flags: string[];
}
export class MergeQuickCommand extends QuickCommandBase<State> {
export class MergeGitCommand extends QuickCommandBase<State> {
constructor() {
super('merge', 'Merge', { description: 'via Terminal' });
}
@ -77,9 +71,9 @@ export class MergeQuickCommand extends QuickCommandBase {
if (state.source === undefined || state.counter < 2) {
const destId = state.destination.id;
const step = this.createPickStep<BranchQuickPickItem>({
const step = this.createPickStep<BranchQuickPickItem | TagQuickPickItem>({
title: `${this.title} into ${state.destination.name}${Strings.pad(GlyphChars.Dot, 2, 2)}${
state.repo.name
state.repo.formattedName
}`,
placeholder: `Choose a branch or tag to merge into ${state.destination.name}`,
items: await getBranchesAndOrTags(state.repo, true, {
@ -105,7 +99,7 @@ export class MergeQuickCommand extends QuickCommandBase {
])) || 0;
if (count === 0) {
const step = this.createConfirmStep(
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.name}`,
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.formattedName}`,
[
{
label: `Cancel ${this.title}`,
@ -121,7 +115,7 @@ export class MergeQuickCommand extends QuickCommandBase {
}
const step = this.createConfirmStep<QuickPickItem & { item: string[] }>(
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.name}`,
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.formattedName}`,
[
{
label: this.title,
@ -162,7 +156,7 @@ export class MergeQuickCommand extends QuickCommandBase {
break;
}
catch (ex) {
if (ex instanceof CommandAbortError) break;
Logger.error(ex, this.title);
throw ex;
}

src/commands/quick/pull.ts → src/commands/git/pull.ts View File

@ -2,10 +2,11 @@
import { QuickPickItem } from 'vscode';
import { Container } from '../../container';
import { Repository } from '../../git/gitService';
import { CommandAbortError, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from './quickCommand';
import { QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import { RepositoryQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { GlyphChars } from '../../constants';
import { Logger } from '../../logger';
interface State {
repos: Repository[];
@ -19,7 +20,7 @@ export interface CommandArgs {
skipConfirmation?: boolean;
}
export class PullQuickCommand extends QuickCommandBase<State> {
export class PullGitCommand extends QuickCommandBase<State> {
constructor(args?: CommandArgs) {
super('pull', 'Pull');
@ -134,7 +135,7 @@ export class PullQuickCommand extends QuickCommandBase {
break;
}
catch (ex) {
if (ex instanceof CommandAbortError) break;
Logger.error(ex, this.title);
throw ex;
}

src/commands/quick/push.ts → src/commands/git/push.ts View File

@ -1,10 +1,11 @@
'use strict';
import { Container } from '../../container';
import { Repository } from '../../git/gitService';
import { CommandAbortError, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from './quickCommand';
import { QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import { RepositoryQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { GlyphChars } from '../../constants';
import { Logger } from '../../logger';
interface State {
repos: Repository[];
@ -18,7 +19,7 @@ export interface CommandArgs {
skipConfirmation?: boolean;
}
export class PushQuickCommand extends QuickCommandBase<State> {
export class PushGitCommand extends QuickCommandBase<State> {
constructor(args?: CommandArgs) {
super('push', 'Push');
@ -140,7 +141,7 @@ export class PushQuickCommand extends QuickCommandBase {
break;
}
catch (ex) {
if (ex instanceof CommandAbortError) break;
Logger.error(ex, this.title);
throw ex;
}

src/commands/quick/rebase.ts → src/commands/git/rebase.ts View File

@ -1,28 +1,22 @@
'use strict';
import { QuickPickItem } from 'vscode';
import { Container } from '../../container';
import { GitBranch, Repository } from '../../git/gitService';
import { GitBranch, GitTag, Repository } from '../../git/gitService';
import { GlyphChars } from '../../constants';
import {
CommandAbortError,
getBranchesAndOrTags,
QuickCommandBase,
QuickInputStep,
QuickPickStep,
StepState
} from './quickCommand';
import { BranchQuickPickItem, RepositoryQuickPickItem } from '../../quickpicks';
import { getBranchesAndOrTags, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import { BranchQuickPickItem, RepositoryQuickPickItem, TagQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { runGitCommandInTerminal } from '../../terminal';
import { Logger } from '../../logger';
interface State {
repo: Repository;
destination: GitBranch;
source: GitBranch;
source: GitBranch | GitTag;
flags: string[];
}
export class RebaseQuickCommand extends QuickCommandBase<State> {
export class RebaseGitCommand extends QuickCommandBase<State> {
constructor() {
super('rebase', 'Rebase', { description: 'via Terminal' });
}
@ -77,9 +71,9 @@ export class RebaseQuickCommand extends QuickCommandBase {
if (state.source === undefined || state.counter < 2) {
const destId = state.destination.id;
const step = this.createPickStep<BranchQuickPickItem>({
const step = this.createPickStep<BranchQuickPickItem | TagQuickPickItem>({
title: `${this.title} ${state.destination.name}${Strings.pad(GlyphChars.Dot, 2, 2)}${
state.repo.name
state.repo.formattedName
}`,
placeholder: `Choose a branch or tag to rebase ${state.destination.name} with`,
items: await getBranchesAndOrTags(state.repo, true, {
@ -105,7 +99,7 @@ export class RebaseQuickCommand extends QuickCommandBase {
])) || 0;
if (count === 0) {
const step = this.createConfirmStep(
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.name}`,
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.formattedName}`,
[
{
label: `Cancel ${this.title}`,
@ -121,7 +115,7 @@ export class RebaseQuickCommand extends QuickCommandBase {
}
const step = this.createConfirmStep<QuickPickItem & { item: string[] }>(
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.name}`,
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.formattedName}`,
[
{
label: this.title,
@ -154,7 +148,7 @@ export class RebaseQuickCommand extends QuickCommandBase {
break;
}
catch (ex) {
if (ex instanceof CommandAbortError) break;
Logger.error(ex, this.title);
throw ex;
}

+ 36
- 22
src/commands/gitCommands.ts View File

@ -2,20 +2,15 @@
import { Disposable, InputBox, QuickInputButtons, QuickPick, QuickPickItem, window } from 'vscode';
import { command, Command, Commands } from './common';
import { log } from '../system';
import {
isQuickInputStep,
isQuickPickStep,
QuickCommandBase,
QuickInputStep,
QuickPickStep
} from './quick/quickCommand';
import { CommandArgs as CheckoutCommandArgs, CheckoutQuickCommand } from './quick/checkout';
import { CherryPickQuickCommand } from './quick/cherry-pick';
import { CommandArgs as FetchCommandArgs, FetchQuickCommand } from './quick/fetch';
import { MergeQuickCommand } from './quick/merge';
import { CommandArgs as PullCommandArgs, PullQuickCommand } from './quick/pull';
import { CommandArgs as PushCommandArgs, PushQuickCommand } from './quick/push';
import { RebaseQuickCommand } from './quick/rebase';
import { isQuickInputStep, isQuickPickStep, QuickCommandBase, QuickInputStep, QuickPickStep } from './quickCommand';
import { BackOrCancelQuickPickItem } from '../quickpicks';
import { CommandArgs as CheckoutCommandArgs, CheckoutGitCommand } from './git/checkout';
import { CherryPickGitCommand } from './git/cherry-pick';
import { CommandArgs as FetchCommandArgs, FetchGitCommand } from './git/fetch';
import { MergeGitCommand } from './git/merge';
import { CommandArgs as PullCommandArgs, PullGitCommand } from './git/pull';
import { CommandArgs as PushCommandArgs, PushGitCommand } from './git/push';
import { RebaseGitCommand } from './git/rebase';
const sanitizeLabel = /\$\(.+?\)|\W/g;
@ -24,18 +19,18 @@ export type GitCommandsCommandArgs = CheckoutCommandArgs | FetchCommandArgs | Pu
class PickCommandStep implements QuickPickStep {
readonly buttons = [];
readonly items: QuickCommandBase[];
readonly placeholder = 'Select command...';
readonly placeholder = 'Choose a git command';
readonly title = 'GitLens';
constructor(args?: GitCommandsCommandArgs) {
this.items = [
new CheckoutQuickCommand(args && args.command === 'checkout' ? args : undefined),
new CherryPickQuickCommand(),
new MergeQuickCommand(),
new FetchQuickCommand(args && args.command === 'fetch' ? args : undefined),
new PullQuickCommand(args && args.command === 'pull' ? args : undefined),
new PushQuickCommand(args && args.command === 'push' ? args : undefined),
new RebaseQuickCommand()
new CheckoutGitCommand(args && args.command === 'checkout' ? args : undefined),
new CherryPickGitCommand(),
new MergeGitCommand(),
new FetchGitCommand(args && args.command === 'fetch' ? args : undefined),
new PullGitCommand(args && args.command === 'pull' ? args : undefined),
new PushGitCommand(args && args.command === 'push' ? args : undefined),
new RebaseGitCommand()
];
}
@ -275,6 +270,25 @@ export class GitCommandsCommand extends Command {
items = quickpick.activeItems;
}
if (items.length === 1) {
const item = items[0];
if (BackOrCancelQuickPickItem.is(item)) {
if (item.cancelled) {
resolve();
return;
}
quickpick.value = '';
if (commandsStep.command !== undefined) {
quickpick.busy = true;
resolve((await commandsStep.command.previous()) || commandsStep);
}
return;
}
}
if (commandsStep.command === undefined) {
const command = items[0];
if (!QuickCommandBase.is(command)) return;

src/commands/quick/quickCommands.helpers.ts → src/commands/quickCommand.helpers.ts View File

@ -1,7 +1,7 @@
'use strict';
import { intersectionWith } from 'lodash-es';
import { GitBranch, GitTag, Repository } from '../../git/git';
import { BranchQuickPickItem, TagQuickPickItem } from '../../quickpicks';
import { GitBranch, GitTag, Repository } from '../git/git';
import { BranchQuickPickItem, TagQuickPickItem } from '../quickpicks';
export async function getBranchesAndOrTags(
repos: Repository | Repository[],

src/commands/quick/quickCommand.ts → src/commands/quickCommand.ts View File

@ -1,8 +1,13 @@
'use strict';
import { InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscode';
import { Promises } from '../../system/promise';
import { Promises } from '../system';
import { BackOrCancelQuickPickItem } from '../quickpicks';
export * from './quickCommands.helpers';
export * from './quickCommand.helpers';
export enum Directive {
Back = 'back'
}
export interface QuickInputStep {
buttons?: QuickInputButton[];
@ -21,7 +26,7 @@ export function isQuickInputStep(item: QuickPickStep | QuickInputStep): item is
export interface QuickPickStep<T extends QuickPickItem = any> {
buttons?: QuickInputButton[];
selectedItems?: QuickPickItem[];
items: QuickPickItem[];
items: (BackOrCancelQuickPickItem | T)[] | BackOrCancelQuickPickItem[];
matchOnDescription?: boolean;
matchOnDetail?: boolean;
multiselect?: boolean;
@ -39,12 +44,6 @@ export function isQuickPickStep(item: QuickPickStep | QuickInputStep): item is Q
return (item as QuickPickStep).items !== undefined;
}
export class CommandAbortError extends Error {
constructor() {
super('Abort');
}
}
export type StepState<T> = Partial<T> & { counter: number; skipConfirmation?: boolean };
export abstract class QuickCommandBase<T = any> implements QuickPickItem {
@ -83,11 +82,10 @@ export abstract class QuickCommandBase implements QuickPickItem {
protected abstract steps(): AsyncIterableIterator<QuickPickStep | QuickInputStep>;
async previous(): Promise<QuickPickStep | QuickInputStep | undefined> {
// Simulate going back, by having no selection
return (await this.next([])).value;
return (await this.next(Directive.Back)).value;
}
async next(value?: QuickPickItem[] | string): Promise<IteratorResult<QuickPickStep | QuickInputStep>> {
async next(value?: QuickPickItem[] | string | Directive): Promise<IteratorResult<QuickPickStep | QuickInputStep>> {
if (this._stepsIterator === undefined) {
this._stepsIterator = this.steps();
}
@ -115,13 +113,8 @@ export abstract class QuickCommandBase implements QuickPickItem {
return this.createPickStep<T>({
placeholder: `Confirm ${this.title}`,
title: title,
items: cancellable ? [...confirmations, { label: 'Cancel' }] : confirmations,
selectedItems: [confirmations[0]],
// eslint-disable-next-line no-loop-func
validate: (selection: T[]) => {
if (selection[0].label === 'Cancel') throw new CommandAbortError();
return true;
}
items: cancellable ? [...confirmations, BackOrCancelQuickPickItem.create()] : confirmations,
selectedItems: [confirmations[0]]
});
}
@ -136,19 +129,19 @@ export abstract class QuickCommandBase implements QuickPickItem {
protected canMoveNext<T extends QuickPickItem>(
step: QuickPickStep<T>,
state: { counter: number },
selection: T[] | undefined
selection: T[] | Directive | undefined
): selection is T[];
protected canMoveNext<T extends string>(
step: QuickInputStep,
state: { counter: number },
value: string | undefined
value: string | Directive | undefined
): boolean | Promise<boolean>;
protected canMoveNext<T extends any>(
step: QuickPickStep | QuickInputStep,
state: { counter: number },
value: T[] | string | undefined
value: T[] | string | Directive | undefined
) {
if (value === undefined || value.length === 0) {
if (value === Directive.Back) {
state.counter--;
if (state.counter < 0) {
state.counter = 0;
@ -164,10 +157,19 @@ export abstract class QuickCommandBase implements QuickPickItem {
if (isQuickInputStep(step)) {
const result = step.validate!(value as string);
if (!Promises.isPromise(result)) {
return result[0];
const [valid] = result;
if (valid) {
state.counter++;
}
return valid;
}
return result.then(([valid]) => valid);
return result.then(([valid]) => {
if (valid) {
state.counter++;
}
return valid;
});
}
return false;

+ 27
- 7
src/quickpicks/gitQuickPicks.ts View File

@ -14,6 +14,26 @@ import {
} from '../git/gitService';
import { emojify } from '../emojis';
export interface BackOrCancelQuickPickItem extends QuickPickItem {
cancelled: boolean;
}
export namespace BackOrCancelQuickPickItem {
export function create(cancelled: boolean = true, picked?: boolean, label?: string) {
const item: BackOrCancelQuickPickItem = {
label: label || (cancelled ? 'Cancel' : 'Back'),
picked: picked,
cancelled: cancelled
};
return item;
}
export function is(item: QuickPickItem): item is BackOrCancelQuickPickItem {
return item != null && 'cancelled' in item;
}
}
export interface BranchQuickPickItem extends QuickPickItem {
readonly item: GitBranch;
readonly current: boolean;
@ -169,6 +189,13 @@ export namespace CommitQuickPickItem {
}
}
export interface RefQuickPickItem extends QuickPickItem {
readonly item: GitReference;
readonly current: boolean;
readonly ref: string;
readonly remote: boolean;
}
export namespace RefQuickPickItem {
export function create(ref: string, picked?: boolean, options: { ref?: boolean } = {}) {
const item: RefQuickPickItem = {
@ -185,13 +212,6 @@ export namespace RefQuickPickItem {
}
}
export interface RefQuickPickItem extends QuickPickItem {
readonly item: GitReference;
readonly current: boolean;
readonly ref: string;
readonly remote: boolean;
}
export interface RepositoryQuickPickItem extends QuickPickItem {
readonly item: Repository;
readonly repoPath: string;

+ 6
- 3
src/views/viewCommands.ts View File

@ -201,7 +201,8 @@ export class ViewCommands {
private fetch(node: RemoteNode | RepositoryNode) {
if (node instanceof RemoteNode) return node.fetch();
if (node instanceof RepositoryNode) {
return commands.executeCommand(Commands.GitCommands, { command: 'fetch', state: { repos: [node.repo] } });
const args: GitCommandsCommandArgs = { command: 'fetch', state: { repos: [node.repo] } };
return commands.executeCommand(Commands.GitCommands, args);
}
return undefined;
@ -213,7 +214,8 @@ export class ViewCommands {
}
if (!(node instanceof RepositoryNode)) return undefined;
return commands.executeCommand(Commands.GitCommands, { command: 'pull', state: { repos: [node.repo] } });
const args: GitCommandsCommandArgs = { command: 'pull', state: { repos: [node.repo] } };
return commands.executeCommand(Commands.GitCommands, args);
}
private push(node: RepositoryNode | BranchTrackingStatusNode, force?: boolean) {
@ -222,7 +224,8 @@ export class ViewCommands {
}
if (!(node instanceof RepositoryNode)) return undefined;
return commands.executeCommand(Commands.GitCommands, { command: 'push', state: { repos: [node.repo] } });
const args: GitCommandsCommandArgs = { command: 'push', state: { repos: [node.repo] } };
return commands.executeCommand(Commands.GitCommands, args);
}
private async applyChanges(node: ViewRefFileNode) {

Loading…
Cancel
Save