mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-12 19:18:32 -05:00
Refactors commands to use typed args objects
This commit is contained in:
@@ -1,34 +1,34 @@
|
||||
'use strict';
|
||||
import { TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCachedCommand, Commands } from './common';
|
||||
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
||||
import { GitService } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks';
|
||||
|
||||
export interface ShowQuickRepoStatusCommandArgs {
|
||||
goBackCommand?: CommandQuickPickItem;
|
||||
}
|
||||
|
||||
export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
|
||||
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.ShowQuickRepoStatus);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, uri?: Uri, goBackCommand?: CommandQuickPickItem) {
|
||||
if (!(uri instanceof Uri)) {
|
||||
uri = editor && editor.document && editor.document.uri;
|
||||
}
|
||||
async execute(editor: TextEditor, uri?: Uri, args: ShowQuickRepoStatusCommandArgs = {}) {
|
||||
uri = getCommandUri(uri, editor);
|
||||
|
||||
try {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show repository status`);
|
||||
|
||||
const status = await this.git.getStatusForRepo(repoPath);
|
||||
if (!status) return window.showWarningMessage(`Unable to show repository status`);
|
||||
if (status === undefined) return window.showWarningMessage(`Unable to show repository status`);
|
||||
|
||||
const pick = await RepoStatusQuickPick.show(status, goBackCommand);
|
||||
if (!pick) return undefined;
|
||||
const pick = await RepoStatusQuickPick.show(status, args.goBackCommand);
|
||||
if (pick === undefined) return undefined;
|
||||
|
||||
if (pick instanceof CommandQuickPickItem) {
|
||||
return pick.execute();
|
||||
}
|
||||
if (pick instanceof CommandQuickPickItem) return pick.execute();
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user