diff --git a/src/commands/quick/checkout.ts b/src/commands/git/checkout.ts similarity index 96% rename from src/commands/quick/checkout.ts rename to src/commands/git/checkout.ts index f8a3b3a..6674228 100644 --- a/src/commands/quick/checkout.ts +++ b/src/commands/git/checkout.ts @@ -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 { +export class CheckoutGitCommand extends QuickCommandBase { 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; } diff --git a/src/commands/quick/cherry-pick.ts b/src/commands/git/cherry-pick.ts similarity index 92% rename from src/commands/quick/cherry-pick.ts rename to src/commands/git/cherry-pick.ts index a50e177..55ceb1f 100644 --- a/src/commands/quick/cherry-pick.ts +++ b/src/commands/git/cherry-pick.ts @@ -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 { +export class CherryPickGitCommand extends QuickCommandBase { constructor() { super('cherry-pick', 'Cherry Pick', { description: 'via Terminal' }); } @@ -86,7 +85,7 @@ export class CherryPickQuickCommand extends QuickCommandBase { const step = this.createPickStep({ 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({ 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; } diff --git a/src/commands/quick/fetch.ts b/src/commands/git/fetch.ts similarity index 96% rename from src/commands/quick/fetch.ts rename to src/commands/git/fetch.ts index 010edfc..4261102 100644 --- a/src/commands/quick/fetch.ts +++ b/src/commands/git/fetch.ts @@ -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 { +export class FetchGitCommand extends QuickCommandBase { 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; } diff --git a/src/commands/quick/merge.ts b/src/commands/git/merge.ts similarity index 91% rename from src/commands/quick/merge.ts rename to src/commands/git/merge.ts index d7f1d42..f4a1c50 100644 --- a/src/commands/quick/merge.ts +++ b/src/commands/git/merge.ts @@ -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 { +export class MergeGitCommand extends QuickCommandBase { 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({ + const step = this.createPickStep({ 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( - `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; } diff --git a/src/commands/quick/pull.ts b/src/commands/git/pull.ts similarity index 95% rename from src/commands/quick/pull.ts rename to src/commands/git/pull.ts index b7bc57e..99ea3f3 100644 --- a/src/commands/quick/pull.ts +++ b/src/commands/git/pull.ts @@ -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 { +export class PullGitCommand extends QuickCommandBase { 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; } diff --git a/src/commands/quick/push.ts b/src/commands/git/push.ts similarity index 95% rename from src/commands/quick/push.ts rename to src/commands/git/push.ts index 5a23b41..f090ae9 100644 --- a/src/commands/quick/push.ts +++ b/src/commands/git/push.ts @@ -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 { +export class PushGitCommand extends QuickCommandBase { 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; } diff --git a/src/commands/quick/rebase.ts b/src/commands/git/rebase.ts similarity index 90% rename from src/commands/quick/rebase.ts rename to src/commands/git/rebase.ts index e411eba..4a86330 100644 --- a/src/commands/quick/rebase.ts +++ b/src/commands/git/rebase.ts @@ -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 { +export class RebaseGitCommand extends QuickCommandBase { 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({ + const step = this.createPickStep({ 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( - `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; } diff --git a/src/commands/gitCommands.ts b/src/commands/gitCommands.ts index ab23ff6..87a1d3c 100644 --- a/src/commands/gitCommands.ts +++ b/src/commands/gitCommands.ts @@ -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; diff --git a/src/commands/quick/quickCommands.helpers.ts b/src/commands/quickCommand.helpers.ts similarity index 95% rename from src/commands/quick/quickCommands.helpers.ts rename to src/commands/quickCommand.helpers.ts index dce54c0..f4751e7 100644 --- a/src/commands/quick/quickCommands.helpers.ts +++ b/src/commands/quickCommand.helpers.ts @@ -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[], diff --git a/src/commands/quick/quickCommand.ts b/src/commands/quickCommand.ts similarity index 80% rename from src/commands/quick/quickCommand.ts rename to src/commands/quickCommand.ts index 540c179..f72acae 100644 --- a/src/commands/quick/quickCommand.ts +++ b/src/commands/quickCommand.ts @@ -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 { 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 = Partial & { counter: number; skipConfirmation?: boolean }; export abstract class QuickCommandBase implements QuickPickItem { @@ -83,11 +82,10 @@ export abstract class QuickCommandBase implements QuickPickItem { protected abstract steps(): AsyncIterableIterator; async previous(): Promise { - // 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> { + async next(value?: QuickPickItem[] | string | Directive): Promise> { if (this._stepsIterator === undefined) { this._stepsIterator = this.steps(); } @@ -115,13 +113,8 @@ export abstract class QuickCommandBase implements QuickPickItem { return this.createPickStep({ 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( step: QuickPickStep, state: { counter: number }, - selection: T[] | undefined + selection: T[] | Directive | undefined ): selection is T[]; protected canMoveNext( step: QuickInputStep, state: { counter: number }, - value: string | undefined + value: string | Directive | undefined ): boolean | Promise; protected canMoveNext( 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; diff --git a/src/quickpicks/gitQuickPicks.ts b/src/quickpicks/gitQuickPicks.ts index f5fda70..7a14339 100644 --- a/src/quickpicks/gitQuickPicks.ts +++ b/src/quickpicks/gitQuickPicks.ts @@ -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; diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index bc9b6b5..955eb2e 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -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) {