diff --git a/docs/telemetry-events.md b/docs/telemetry-events.md index f06ae3a63adb1..23c0e16bc9756 100644 --- a/docs/telemetry-events.md +++ b/docs/telemetry-events.md @@ -1783,7 +1783,7 @@ or ```typescript { 'usage.count': number, - 'usage.key': 'graphWebview:shown' | 'patchDetailsWebview:shown' | 'settingsWebview:shown' | 'timelineWebview:shown' | 'graphView:shown' | 'patchDetailsView:shown' | 'timelineView:shown' | 'commitDetailsView:shown' | 'graphDetailsView:shown' | 'homeView:shown' | 'commitsView:shown' | 'stashesView:shown' | 'tagsView:shown' | 'launchpadView:shown' | 'worktreesView:shown' | 'branchesView:shown' | 'contributorsView:shown' | 'draftsView:shown' | 'fileHistoryView:shown' | 'scm.groupedView:shown' | 'lineHistoryView:shown' | 'pullRequestView:shown' | 'remotesView:shown' | 'repositoriesView:shown' | 'searchAndCompareView:shown' | 'workspacesView:shown' | 'rebaseEditor:shown' | 'command:gitlens.action.:executed' | 'command:gitlens.addAuthors:executed' | 'command:gitlens.browseRepoAtRevision:executed' | 'command:gitlens.browseRepoAtRevisionInNewWindow:executed' | 'command:gitlens.browseRepoBeforeRevision:executed' | 'command:gitlens.browseRepoBeforeRevisionInNewWindow:executed' | 'command:gitlens.clearFileAnnotations:executed' | 'command:gitlens.closeUnchangedFiles:executed' | 'command:gitlens.compareWith:executed' | 'command:gitlens.compareHeadWith:executed' | 'command:gitlens.compareWorkingWith:executed' | 'command:gitlens.computingFileAnnotations:executed' | 'command:gitlens.connectRemoteProvider:executed' | 'command:gitlens.copyCurrentBranch:executed' | 'command:gitlens.copyDeepLinkToBranch:executed' | 'command:gitlens.copyDeepLinkToCommit:executed' | 'command:gitlens.copyDeepLinkToComparison:executed' | 'command:gitlens.copyDeepLinkToFile:executed' | 'command:gitlens.copyDeepLinkToFileAtRevision:executed' | 'command:gitlens.copyDeepLinkToLines:executed' | 'command:gitlens.copyDeepLinkToRepo:executed' | 'command:gitlens.copyDeepLinkToTag:executed' | 'command:gitlens.copyDeepLinkToWorkspace:executed' | 'command:gitlens.copyMessageToClipboard:executed' | 'command:gitlens.copyRemoteBranchesUrl:executed' | 'command:gitlens.copyRemoteBranchUrl:executed' | 'command:gitlens.copyRemoteCommitUrl:executed' | 'command:gitlens.copyRemoteComparisonUrl:executed' | 'command:gitlens.copyRemoteFileUrlToClipboard:executed' | 'command:gitlens.copyRemoteFileUrlWithoutRange:executed' | 'command:gitlens.copyRemoteFileUrlFrom:executed' | 'command:gitlens.copyRemotePullRequestUrl:executed' | 'command:gitlens.copyRemoteRepositoryUrl:executed' | 'command:gitlens.copyShaToClipboard:executed' | 'command:gitlens.copyRelativePathToClipboard:executed' | 'command:gitlens.applyPatchFromClipboard:executed' | 'command:gitlens.pastePatchFromClipboard:executed' | 'command:gitlens.copyPatchToClipboard:executed' | 'command:gitlens.copyWorkingChangesToWorktree:executed' | 'command:gitlens.createPatch:executed' | 'command:gitlens.createCloudPatch:executed' | 'command:gitlens.createPullRequestOnRemote:executed' | 'command:gitlens.diffDirectory:executed' | 'command:gitlens.diffDirectoryWithHead:executed' | 'command:gitlens.diffFolderWithRevision:executed' | 'command:gitlens.diffFolderWithRevisionFrom:executed' | 'command:gitlens.diffWith:executed' | 'command:gitlens.diffWithNext:executed' | 'command:gitlens.diffWithNextInDiffLeft:executed' | 'command:gitlens.diffWithNextInDiffRight:executed' | 'command:gitlens.diffWithPrevious:executed' | 'command:gitlens.diffWithPreviousInDiffLeft:executed' | 'command:gitlens.diffWithPreviousInDiffRight:executed' | 'command:gitlens.diffLineWithPrevious:executed' | 'command:gitlens.diffWithRevision:executed' | 'command:gitlens.diffWithRevisionFrom:executed' | 'command:gitlens.diffWithWorking:executed' | 'command:gitlens.diffWithWorkingInDiffLeft:executed' | 'command:gitlens.diffWithWorkingInDiffRight:executed' | 'command:gitlens.diffLineWithWorking:executed' | 'command:gitlens.disconnectRemoteProvider:executed' | 'command:gitlens.disableDebugLogging:executed' | 'command:gitlens.enableDebugLogging:executed' | 'command:gitlens.disableRebaseEditor:executed' | 'command:gitlens.enableRebaseEditor:executed' | 'command:gitlens.externalDiff:executed' | 'command:gitlens.externalDiffAll:executed' | 'command:gitlens.fetchRepositories:executed' | 'command:gitlens.generateCommitMessage:executed' | 'command:gitlens.scm.generateCommitMessage:executed' | 'command:gitlens.getStarted:executed' | 'command:gitlens.gk.switchOrganization:executed' | 'command:gitlens.inviteToLiveShare:executed' | 'command:gitlens.openBlamePriorToChange:executed' | 'command:gitlens.openBranchesOnRemote:executed' | 'command:gitlens.openBranchOnRemote:executed' | 'command:gitlens.openCurrentBranchOnRemote:executed' | 'command:gitlens.openChangedFiles:executed' | 'command:gitlens.openCommitOnRemote:executed' | 'command:gitlens.openComparisonOnRemote:executed' | 'command:gitlens.openFileHistory:executed' | 'command:gitlens.openFileFromRemote:executed' | 'command:gitlens.openFileOnRemote:executed' | 'command:gitlens.openFileOnRemoteFrom:executed' | 'command:gitlens.openFileRevision:executed' | 'command:gitlens.openFileRevisionFrom:executed' | 'command:gitlens.openFolderHistory:executed' | 'command:gitlens.openOnRemote:executed' | 'command:gitlens.openCloudPatch:executed' | 'command:gitlens.openPatch:executed' | 'command:gitlens.openPullRequestOnRemote:executed' | 'command:gitlens.openAssociatedPullRequestOnRemote:executed' | 'command:gitlens.openRepoOnRemote:executed' | 'command:gitlens.openRevisionFile:executed' | 'command:gitlens.openRevisionFileInDiffLeft:executed' | 'command:gitlens.openRevisionFileInDiffRight:executed' | 'command:gitlens.openWalkthrough:executed' | 'command:gitlens.openWorkingFile:executed' | 'command:gitlens.openWorkingFileInDiffLeft:executed' | 'command:gitlens.openWorkingFileInDiffRight:executed' | 'command:gitlens.pullRepositories:executed' | 'command:gitlens.pushRepositories:executed' | 'command:gitlens.gitCommands:executed' | 'command:gitlens.gitCommands.branch:executed' | 'command:gitlens.gitCommands.branch.create:executed' | 'command:gitlens.gitCommands.branch.delete:executed' | 'command:gitlens.gitCommands.branch.prune:executed' | 'command:gitlens.gitCommands.branch.rename:executed' | 'command:gitlens.gitCommands.checkout:executed' | 'command:gitlens.gitCommands.cherryPick:executed' | 'command:gitlens.gitCommands.history:executed' | 'command:gitlens.gitCommands.merge:executed' | 'command:gitlens.gitCommands.rebase:executed' | 'command:gitlens.gitCommands.remote:executed' | 'command:gitlens.gitCommands.remote.add:executed' | 'command:gitlens.gitCommands.remote.prune:executed' | 'command:gitlens.gitCommands.remote.remove:executed' | 'command:gitlens.gitCommands.reset:executed' | 'command:gitlens.gitCommands.revert:executed' | 'command:gitlens.gitCommands.show:executed' | 'command:gitlens.gitCommands.stash:executed' | 'command:gitlens.gitCommands.stash.drop:executed' | 'command:gitlens.gitCommands.stash.list:executed' | 'command:gitlens.gitCommands.stash.pop:executed' | 'command:gitlens.gitCommands.stash.push:executed' | 'command:gitlens.gitCommands.stash.rename:executed' | 'command:gitlens.gitCommands.status:executed' | 'command:gitlens.gitCommands.switch:executed' | 'command:gitlens.gitCommands.tag:executed' | 'command:gitlens.gitCommands.tag.create:executed' | 'command:gitlens.gitCommands.tag.delete:executed' | 'command:gitlens.gitCommands.worktree:executed' | 'command:gitlens.gitCommands.worktree.create:executed' | 'command:gitlens.gitCommands.worktree.delete:executed' | 'command:gitlens.gitCommands.worktree.open:executed' | 'command:gitlens.ghpr.views.openOrCreateWorktree:executed' | 'command:gitlens.plus.cloudIntegrations.connect:executed' | 'command:gitlens.plus.hide:executed' | 'command:gitlens.plus.login:executed' | 'command:gitlens.plus.logout:executed' | 'command:gitlens.plus.manage:executed' | 'command:gitlens.plus.cloudIntegrations.manage:executed' | 'command:gitlens.plus.reactivateProTrial:executed' | 'command:gitlens.plus.resendVerification:executed' | 'command:gitlens.plus.restore:executed' | 'command:gitlens.plus.showPlans:executed' | 'command:gitlens.plus.signUp:executed' | 'command:gitlens.plus.startPreviewTrial:executed' | 'command:gitlens.plus.continueFeaturePreview:executed' | 'command:gitlens.plus.upgrade:executed' | 'command:gitlens.plus.validate:executed' | 'command:gitlens.plus.simulateSubscription:executed' | 'command:gitlens.quickOpenFileHistory:executed' | 'command:gitlens.launchpad.refresh:executed' | 'command:gitlens.graph.refresh:executed' | 'command:gitlens.refreshHover:executed' | 'command:gitlens.reset:executed' | 'command:gitlens.resetAIKey:executed' | 'command:gitlens.resetViewsLayout:executed' | 'command:gitlens.revealCommitInView:executed' | 'command:gitlens.shareAsCloudPatch:executed' | 'command:gitlens.showCommitSearch:executed' | 'command:gitlens.views.searchAndCompare.searchCommits:executed' | 'command:gitlens.showBranchesView:executed' | 'command:gitlens.showCommitDetailsView:executed' | 'command:gitlens.showCommitInView:executed' | 'command:gitlens.showCommitsInView:executed' | 'command:gitlens.showCommitsView:executed' | 'command:gitlens.showContributorsView:executed' | 'command:gitlens.showDraftsView:executed' | 'command:gitlens.showFileHistoryView:executed' | 'command:gitlens.showGraph:executed' | 'command:gitlens.showGraphPage:executed' | 'command:gitlens.showGraphView:executed' | 'command:gitlens.showHomeView:executed' | 'command:gitlens.showAccountView:executed' | 'command:gitlens.showInCommitGraph:executed' | 'command:gitlens.showInCommitGraphView:executed' | 'command:gitlens.showInDetailsView:executed' | 'command:gitlens.showInTimeline:executed' | 'command:gitlens.showLastQuickPick:executed' | 'command:gitlens.showLaunchpad:executed' | 'command:gitlens.showLaunchpadView:executed' | 'command:gitlens.showLineCommitInView:executed' | 'command:gitlens.showLineHistoryView:executed' | 'command:gitlens.openOnlyChangedFiles:executed' | 'command:gitlens.showPatchDetailsPage:executed' | 'command:gitlens.showQuickBranchHistory:executed' | 'command:gitlens.showQuickCommitDetails:executed' | 'command:gitlens.showQuickCommitFileDetails:executed' | 'command:gitlens.showQuickRepoHistory:executed' | 'command:gitlens.showQuickFileHistory:executed' | 'command:gitlens.showQuickRepoStatus:executed' | 'command:gitlens.showQuickRevisionDetails:executed' | 'command:gitlens.showQuickRevisionDetailsInDiffLeft:executed' | 'command:gitlens.showQuickRevisionDetailsInDiffRight:executed' | 'command:gitlens.showQuickStashList:executed' | 'command:gitlens.showRemotesView:executed' | 'command:gitlens.showRepositoriesView:executed' | 'command:gitlens.showSearchAndCompareView:executed' | 'command:gitlens.showSettingsPage:executed' | 'command:gitlens.showSettingsPage!file-annotations:executed' | 'command:gitlens.showSettingsPage!branches-view:executed' | 'command:gitlens.showSettingsPage!commits-view:executed' | 'command:gitlens.showSettingsPage!contributors-view:executed' | 'command:gitlens.showSettingsPage!file-history-view:executed' | 'command:gitlens.showSettingsPage!line-history-view:executed' | 'command:gitlens.showSettingsPage!remotes-view:executed' | 'command:gitlens.showSettingsPage!repositories-view:executed' | 'command:gitlens.showSettingsPage!search-compare-view:executed' | 'command:gitlens.showSettingsPage!stashes-view:executed' | 'command:gitlens.showSettingsPage!tags-view:executed' | 'command:gitlens.showSettingsPage!worktrees-view:executed' | 'command:gitlens.showSettingsPage!views:executed' | 'command:gitlens.showSettingsPage!commit-graph:executed' | 'command:gitlens.showSettingsPage!autolinks:executed' | 'command:gitlens.showStashesView:executed' | 'command:gitlens.showTagsView:executed' | 'command:gitlens.showTimelinePage:executed' | 'command:gitlens.showTimelineView:executed' | 'command:gitlens.showWorktreesView:executed' | 'command:gitlens.showWorkspacesView:executed' | 'command:gitlens.startWork:executed' | 'command:gitlens.stashApply:executed' | 'command:gitlens.stashSave:executed' | 'command:gitlens.stashSaveFiles:executed' | 'command:gitlens.switchAIModel:executed' | 'command:gitlens.switchMode:executed' | 'command:gitlens.toggleCodeLens:executed' | 'command:gitlens.toggleFileBlame:executed' | 'command:gitlens.toggleFileBlameInDiffLeft:executed' | 'command:gitlens.toggleFileBlameInDiffRight:executed' | 'command:gitlens.toggleFileChanges:executed' | 'command:gitlens.toggleFileChangesOnly:executed' | 'command:gitlens.toggleFileHeatmap:executed' | 'command:gitlens.toggleFileHeatmapInDiffLeft:executed' | 'command:gitlens.toggleFileHeatmapInDiffRight:executed' | 'command:gitlens.launchpad.indicator.toggle:executed' | 'command:gitlens.toggleGraph:executed' | 'command:gitlens.toggleMaximizedGraph:executed' | 'command:gitlens.toggleLineBlame:executed' | 'command:gitlens.toggleReviewMode:executed' | 'command:gitlens.toggleZenMode:executed' | 'command:gitlens.views.copy:executed' | 'command:gitlens.views.copyAsMarkdown:executed' | 'command:gitlens.views.copyUrl:executed' | 'command:gitlens.views.openChangedFileDiffs:executed' | 'command:gitlens.views.openDirectoryDiff:executed' | 'command:gitlens.views.openDirectoryDiffWithWorking:executed' | 'command:gitlens.views.openUrl:executed' | 'command:gitlens.walkthrough.connectIntegrations:executed' | 'command:gitlens.walkthrough.gitlensInspect:executed' | 'command:gitlens.walkthrough.openAcceleratePrReviews:executed' | 'command:gitlens.walkthrough.openCommunityVsPro:executed' | 'command:gitlens.walkthrough.openHelpCenter:executed' | 'command:gitlens.walkthrough.openInteractiveCodeHistory:executed' | 'command:gitlens.walkthrough.openStartIntegrations:executed' | 'command:gitlens.walkthrough.openStreamlineCollaboration:executed' | 'command:gitlens.walkthrough.openWalkthrough:executed' | 'command:gitlens.walkthrough.plus.signUp:executed' | 'command:gitlens.walkthrough.plus.upgrade:executed' | 'command:gitlens.walkthrough.plus.reactivate:executed' | 'command:gitlens.walkthrough.showAutolinks:executed' | 'command:gitlens.walkthrough.showDraftsView:executed' | 'command:gitlens.walkthrough.showGraph:executed' | 'command:gitlens.walkthrough.showLaunchpad:executed' | 'command:gitlens.walkthrough.worktree.create:executed' | 'command:gitlens.walkthrough.openDevExPlatform:executed' | 'command:gitlens.diffHeadWith:executed' | 'command:gitlens.diffWorkingWith:executed' | 'command:gitlens.openBranchesInRemote:executed' | 'command:gitlens.openBranchInRemote:executed' | 'command:gitlens.openCommitInRemote:executed' | 'command:gitlens.openFileInRemote:executed' | 'command:gitlens.openInRemote:executed' | 'command:gitlens.openRepoInRemote:executed' | 'command:gitlens.showFileHistoryInView:executed' | 'home:walkthrough:dismissed' + 'usage.key': 'graphWebview:shown' | 'patchDetailsWebview:shown' | 'settingsWebview:shown' | 'timelineWebview:shown' | 'graphView:shown' | 'patchDetailsView:shown' | 'timelineView:shown' | 'commitDetailsView:shown' | 'graphDetailsView:shown' | 'homeView:shown' | 'commitsView:shown' | 'stashesView:shown' | 'tagsView:shown' | 'launchpadView:shown' | 'worktreesView:shown' | 'branchesView:shown' | 'contributorsView:shown' | 'draftsView:shown' | 'fileHistoryView:shown' | 'scm.groupedView:shown' | 'lineHistoryView:shown' | 'pullRequestView:shown' | 'remotesView:shown' | 'repositoriesView:shown' | 'searchAndCompareView:shown' | 'workspacesView:shown' | 'rebaseEditor:shown' | `command:${string}:executed` | 'home:walkthrough:dismissed' } ``` diff --git a/src/api/actionRunners.ts b/src/api/actionRunners.ts index 351d333ca0b96..bd0fc5ef2180a 100644 --- a/src/api/actionRunners.ts +++ b/src/api/actionRunners.ts @@ -1,7 +1,7 @@ import type { Event, QuickPickItem } from 'vscode'; import { Disposable, EventEmitter, window } from 'vscode'; import type { Config } from '../config'; -import { Commands } from '../constants.commands'; +import { actionCommandPrefix } from '../constants.commands'; import type { Container } from '../container'; import { getScopedCounter } from '../system/counter'; import { sortCompare } from '../system/string'; @@ -137,7 +137,7 @@ export class ActionRunners implements Disposable { for (const action of actions) { subscriptions.push( - registerCommand(`${Commands.ActionPrefix}${action}`, (context: ActionContext, runnerId?: number) => + registerCommand(`${actionCommandPrefix}${action}`, (context: ActionContext, runnerId?: number) => this.run(context, runnerId), ), ); diff --git a/src/codelens/codeLensProvider.ts b/src/codelens/codeLensProvider.ts index 249a7d525d359..4580501f38393 100644 --- a/src/codelens/codeLensProvider.ts +++ b/src/codelens/codeLensProvider.ts @@ -19,7 +19,8 @@ import type { ToggleFileChangesAnnotationCommandArgs } from '../commands/toggleF import type { CodeLensConfig, CodeLensLanguageScope } from '../config'; import { CodeLensCommand } from '../config'; import { trackableSchemes } from '../constants'; -import { Commands } from '../constants.commands'; +import type { GlCommands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import type { GitUri } from '../git/gitUri'; import type { GitBlame } from '../git/models/blame'; @@ -611,7 +612,7 @@ function applyDiffWithPreviousCommand( - Commands.DiffWithPrevious, + GlCommand.DiffWithPrevious, title, undefined, { @@ -628,7 +629,7 @@ function applyCopyOrOpenCommitOnRemoteCommand(Commands.OpenOnRemote, title, { + lens.command = createCommand<[OpenOnRemoteCommandArgs]>(GlCommand.OpenOnRemote, title, { resource: { type: RemoteResourceType.Commit, sha: commit.sha, @@ -645,7 +646,7 @@ function applyCopyOrOpenFileOnRemoteCommand(Commands.OpenOnRemote, title, { + lens.command = createCommand<[OpenOnRemoteCommandArgs]>(GlCommand.OpenOnRemote, title, { resource: { type: RemoteResourceType.Revision, fileName: commit.file?.path ?? '', @@ -688,7 +689,7 @@ function applyShowCommitsInViewCommand( - refs.length === 0 ? ('' as Commands) : Commands.ShowCommitsInView, + refs.length === 0 ? ('' as GlCommands) : GlCommand.ShowCommitsInView, title, { repoPath: blame.repoPath, @@ -759,7 +760,7 @@ function applyToggleFileBlameCommand(Commands.ToggleFileBlame, title, lens.uri!.toFileUri()); + lens.command = createCommand<[Uri]>(GlCommand.ToggleFileBlame, title, lens.uri!.toFileUri()); return lens; } @@ -770,7 +771,7 @@ function applyToggleFileChangesCommand( - Commands.ToggleFileChanges, + GlCommand.ToggleFileChanges, title, lens.uri!.toFileUri(), { @@ -785,7 +786,7 @@ function applyToggleFileHeatmapCommand(Commands.ToggleFileHeatmap, title, lens.uri!.toFileUri()); + lens.command = createCommand<[Uri]>(GlCommand.ToggleFileHeatmap, title, lens.uri!.toFileUri()); return lens; } diff --git a/src/commands/addAuthors.ts b/src/commands/addAuthors.ts index 9d92ce6ab17e1..38d087d6cc676 100644 --- a/src/commands/addAuthors.ts +++ b/src/commands/addAuthors.ts @@ -1,14 +1,14 @@ import type { SourceControl } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class AddAuthorsCommand extends Command { +export class AddAuthorsCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.AddAuthors); + super(GlCommand.AddAuthors); } execute(sourceControl: SourceControl) { diff --git a/src/commands/base.ts b/src/commands/base.ts index dc1c48c80379f..13f5c6158948b 100644 --- a/src/commands/base.ts +++ b/src/commands/base.ts @@ -8,7 +8,7 @@ import type { TimelineItem, } from 'vscode'; import { commands, Disposable, Uri, window } from 'vscode'; -import type { Commands } from '../constants.commands'; +import type { GlCommands } from '../constants.commands'; import type { StoredNamedRef } from '../constants.storage'; import type { GitBranch } from '../git/models/branch'; import { isBranch } from '../git/models/branch'; @@ -282,12 +282,12 @@ function isGitTimelineItem(item: any): item is GitTimelineItem { ); } -export abstract class Command implements Disposable { +export abstract class GlCommandBase implements Disposable { protected readonly contextParsingOptions: CommandContextParsingOptions = { expectsEditor: false }; private readonly _disposable: Disposable; - constructor(command: Commands | Commands[]) { + constructor(command: GlCommands | GlCommands[]) { if (typeof command === 'string') { this._disposable = registerCommand(command, (...args: any[]) => this._execute(command, ...args), this); @@ -447,7 +447,7 @@ export function parseCommandContext( return [{ command: command, type: 'unknown', editor: editor, uri: editor?.document.uri }, args]; } -export abstract class ActiveEditorCommand extends Command { +export abstract class ActiveEditorCommand extends GlCommandBase { protected override readonly contextParsingOptions: CommandContextParsingOptions = { expectsEditor: true }; protected override preExecute(context: CommandContext, ...args: any[]): Promise { @@ -482,7 +482,7 @@ export abstract class ActiveEditorCachedCommand extends ActiveEditorCommand { export abstract class EditorCommand implements Disposable { private readonly _disposable: Disposable; - constructor(command: Commands | Commands[]) { + constructor(command: GlCommands | GlCommands[]) { if (!Array.isArray(command)) { command = [command]; } diff --git a/src/commands/browseRepoAtRevision.ts b/src/commands/browseRepoAtRevision.ts index 9d2abdc121540..71ba436a14c4b 100644 --- a/src/commands/browseRepoAtRevision.ts +++ b/src/commands/browseRepoAtRevision.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { showGenericErrorMessage } from '../messages'; @@ -21,22 +21,22 @@ export interface BrowseRepoAtRevisionCommandArgs { export class BrowseRepoAtRevisionCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { super([ - Commands.BrowseRepoAtRevision, - Commands.BrowseRepoAtRevisionInNewWindow, - Commands.BrowseRepoBeforeRevision, - Commands.BrowseRepoBeforeRevisionInNewWindow, + GlCommand.BrowseRepoAtRevision, + GlCommand.BrowseRepoAtRevisionInNewWindow, + GlCommand.BrowseRepoBeforeRevision, + GlCommand.BrowseRepoBeforeRevisionInNewWindow, ]); } protected override preExecute(context: CommandContext, args?: BrowseRepoAtRevisionCommandArgs) { switch (context.command) { - case Commands.BrowseRepoAtRevisionInNewWindow: + case GlCommand.BrowseRepoAtRevisionInNewWindow: args = { ...args, before: false, openInNewWindow: true }; break; - case Commands.BrowseRepoBeforeRevision: + case GlCommand.BrowseRepoBeforeRevision: args = { ...args, before: true, openInNewWindow: false }; break; - case Commands.BrowseRepoBeforeRevisionInNewWindow: + case GlCommand.BrowseRepoBeforeRevisionInNewWindow: args = { ...args, before: true, openInNewWindow: true }; break; } diff --git a/src/commands/closeUnchangedFiles.ts b/src/commands/closeUnchangedFiles.ts index 6831d8db85ac2..5878b0fd4644a 100644 --- a/src/commands/closeUnchangedFiles.ts +++ b/src/commands/closeUnchangedFiles.ts @@ -1,22 +1,22 @@ import type { Uri } from 'vscode'; import { TabInputCustom, TabInputNotebook, TabInputNotebookDiff, TabInputText, TabInputTextDiff, window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { showGenericErrorMessage } from '../messages'; import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { UriComparer } from '../system/comparers'; import { Logger } from '../system/logger'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; export interface CloseUnchangedFilesCommandArgs { uris?: Uri[]; } @command() -export class CloseUnchangedFilesCommand extends Command { +export class CloseUnchangedFilesCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.CloseUnchangedFiles); + super(GlCommand.CloseUnchangedFiles); } async execute(args?: CloseUnchangedFilesCommandArgs) { diff --git a/src/commands/cloudIntegrations.ts b/src/commands/cloudIntegrations.ts index a6cf025938c93..71d5ef78e8b98 100644 --- a/src/commands/cloudIntegrations.ts +++ b/src/commands/cloudIntegrations.ts @@ -1,10 +1,10 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { SupportedCloudIntegrationIds } from '../constants.integrations'; import type { Source } from '../constants.telemetry'; import type { Container } from '../container'; import { createMarkdownCommandLink } from '../system/commands'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; export interface ManageCloudIntegrationsCommandArgs extends Source {} @@ -13,9 +13,9 @@ export interface ConnectCloudIntegrationsCommandArgs extends Source { } @command() -export class ManageCloudIntegrationsCommand extends Command { +export class ManageCloudIntegrationsCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.PlusManageCloudIntegrations); + super(GlCommand.PlusManageCloudIntegrations); } async execute(args?: ManageCloudIntegrationsCommandArgs) { @@ -26,16 +26,16 @@ export class ManageCloudIntegrationsCommand extends Command { } @command() -export class ConnectCloudIntegrationsCommand extends Command { +export class ConnectCloudIntegrationsCommand extends GlCommandBase { static createMarkdownCommandLink(args: ConnectCloudIntegrationsCommandArgs): string { return createMarkdownCommandLink( - Commands.PlusConnectCloudIntegrations, + GlCommand.PlusConnectCloudIntegrations, args, ); } constructor(private readonly container: Container) { - super(Commands.PlusConnectCloudIntegrations); + super(GlCommand.PlusConnectCloudIntegrations); } async execute(args?: ConnectCloudIntegrationsCommandArgs) { diff --git a/src/commands/compareWith.ts b/src/commands/compareWith.ts index 7dea607361193..f88fc7ec22082 100644 --- a/src/commands/compareWith.ts +++ b/src/commands/compareWith.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { showGenericErrorMessage } from '../messages'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; @@ -17,28 +17,28 @@ export interface CompareWithCommandArgs { export class CompareWithCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { super([ - Commands.CompareWith, - Commands.CompareHeadWith, - Commands.CompareWorkingWith, - Commands.Deprecated_DiffHeadWith, - Commands.Deprecated_DiffWorkingWith, + GlCommand.CompareWith, + GlCommand.CompareHeadWith, + GlCommand.CompareWorkingWith, + GlCommand.Deprecated_DiffHeadWith, + GlCommand.Deprecated_DiffWorkingWith, ]); } protected override preExecute(context: CommandContext, args?: CompareWithCommandArgs) { switch (context.command) { - case Commands.CompareWith: + case GlCommand.CompareWith: args = { ...args }; break; - case Commands.CompareHeadWith: - case Commands.Deprecated_DiffHeadWith: + case GlCommand.CompareHeadWith: + case GlCommand.Deprecated_DiffHeadWith: args = { ...args }; args.ref1 = 'HEAD'; break; - case Commands.CompareWorkingWith: - case Commands.Deprecated_DiffWorkingWith: + case GlCommand.CompareWorkingWith: + case GlCommand.Deprecated_DiffWorkingWith: args = { ...args }; args.ref1 = ''; break; diff --git a/src/commands/copyCurrentBranch.ts b/src/commands/copyCurrentBranch.ts index b5a62d0aeaf3c..19fecd3dd0c4d 100644 --- a/src/commands/copyCurrentBranch.ts +++ b/src/commands/copyCurrentBranch.ts @@ -1,6 +1,6 @@ import type { TextEditor, Uri } from 'vscode'; import { env } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { showGenericErrorMessage } from '../messages'; @@ -12,7 +12,7 @@ import { ActiveEditorCommand, getCommandUri } from './base'; @command() export class CopyCurrentBranchCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.CopyCurrentBranch); + super(GlCommand.CopyCurrentBranch); } async execute(editor?: TextEditor, uri?: Uri) { diff --git a/src/commands/copyDeepLink.ts b/src/commands/copyDeepLink.ts index 1398db4f9d2d3..96523703e81dc 100644 --- a/src/commands/copyDeepLink.ts +++ b/src/commands/copyDeepLink.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { StoredNamedRef } from '../constants.storage'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; @@ -40,12 +40,12 @@ export interface CopyDeepLinkCommandArgs { export class CopyDeepLinkCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { super([ - Commands.CopyDeepLinkToBranch, - Commands.CopyDeepLinkToCommit, - Commands.CopyDeepLinkToRepo, - Commands.CopyDeepLinkToTag, - Commands.CopyDeepLinkToComparison, - Commands.CopyDeepLinkToWorkspace, + GlCommand.CopyDeepLinkToBranch, + GlCommand.CopyDeepLinkToCommit, + GlCommand.CopyDeepLinkToRepo, + GlCommand.CopyDeepLinkToTag, + GlCommand.CopyDeepLinkToComparison, + GlCommand.CopyDeepLinkToWorkspace, ]); } @@ -60,7 +60,7 @@ export class CopyDeepLinkCommand extends ActiveEditorCommand { compareWithRef: context.node.compareWithRef, }; } else if (isCommandContextViewNodeHasBranch(context)) { - if (context.command === Commands.CopyDeepLinkToRepo) { + if (context.command === GlCommand.CopyDeepLinkToRepo) { args = { refOrRepoPath: context.node.branch.repoPath, remote: context.node.branch.getRemoteName(), @@ -182,7 +182,7 @@ export interface CopyFileDeepLinkCommandArgs { @command() export class CopyFileDeepLinkCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.CopyDeepLinkToFile, Commands.CopyDeepLinkToFileAtRevision, Commands.CopyDeepLinkToLines]); + super([GlCommand.CopyDeepLinkToFile, GlCommand.CopyDeepLinkToFileAtRevision, GlCommand.CopyDeepLinkToLines]); } protected override preExecute(context: CommandContext, args?: CopyFileDeepLinkCommandArgs) { @@ -190,11 +190,11 @@ export class CopyFileDeepLinkCommand extends ActiveEditorCommand { args = {}; } - if (args.ref == null && context.command === Commands.CopyDeepLinkToFileAtRevision) { + if (args.ref == null && context.command === GlCommand.CopyDeepLinkToFileAtRevision) { args.chooseRef = true; } - if (args.lines == null && context.command === Commands.CopyDeepLinkToLines) { + if (args.lines == null && context.command === GlCommand.CopyDeepLinkToLines) { let lines: number[] | undefined; if (isCommandContextEditorLine(context) && context.line != null) { lines = [context.line + 1]; diff --git a/src/commands/copyMessageToClipboard.ts b/src/commands/copyMessageToClipboard.ts index 03135295878be..369e349cf5957 100644 --- a/src/commands/copyMessageToClipboard.ts +++ b/src/commands/copyMessageToClipboard.ts @@ -1,6 +1,6 @@ import type { TextEditor, Uri } from 'vscode'; import { env } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { copyMessageToClipboard } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; @@ -26,7 +26,7 @@ export interface CopyMessageToClipboardCommandArgs { @command() export class CopyMessageToClipboardCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.CopyMessageToClipboard); + super(GlCommand.CopyMessageToClipboard); } protected override async preExecute(context: CommandContext, args?: CopyMessageToClipboardCommandArgs) { diff --git a/src/commands/copyRelativePathToClipboard.ts b/src/commands/copyRelativePathToClipboard.ts index 263189f1a1871..e1cd59d767b9c 100644 --- a/src/commands/copyRelativePathToClipboard.ts +++ b/src/commands/copyRelativePathToClipboard.ts @@ -1,6 +1,6 @@ import type { TextEditor, Uri } from 'vscode'; import { env } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { command } from '../system/vscode/command'; import type { CommandContext } from './base'; @@ -9,7 +9,7 @@ import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasFileComm @command() export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.CopyRelativePathToClipboard); + super(GlCommand.CopyRelativePathToClipboard); } protected override preExecute(context: CommandContext) { diff --git a/src/commands/copyShaToClipboard.ts b/src/commands/copyShaToClipboard.ts index d5e4de7b74197..91126e0bf768d 100644 --- a/src/commands/copyShaToClipboard.ts +++ b/src/commands/copyShaToClipboard.ts @@ -1,6 +1,6 @@ import type { TextEditor, Uri } from 'vscode'; import { env } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { shortenRevision } from '../git/models/reference'; @@ -25,7 +25,7 @@ export interface CopyShaToClipboardCommandArgs { @command() export class CopyShaToClipboardCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.CopyShaToClipboard); + super(GlCommand.CopyShaToClipboard); } protected override preExecute(context: CommandContext, args?: CopyShaToClipboardCommandArgs) { diff --git a/src/commands/createPullRequestOnRemote.ts b/src/commands/createPullRequestOnRemote.ts index a5f7201ab1f3f..c63efce67294e 100644 --- a/src/commands/createPullRequestOnRemote.ts +++ b/src/commands/createPullRequestOnRemote.ts @@ -1,5 +1,5 @@ import { window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { getRemoteNameFromBranchName } from '../git/models/branch'; import type { GitRemote } from '../git/models/remote'; @@ -8,7 +8,7 @@ import { RemoteResourceType } from '../git/models/remoteResource'; import type { RemoteProvider } from '../git/remotes/remoteProvider'; import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command, executeCommand } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; import type { OpenOnRemoteCommandArgs } from './openOnRemote'; export interface CreatePullRequestOnRemoteCommandArgs { @@ -21,9 +21,9 @@ export interface CreatePullRequestOnRemoteCommandArgs { } @command() -export class CreatePullRequestOnRemoteCommand extends Command { +export class CreatePullRequestOnRemoteCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.CreatePullRequestOnRemote); + super(GlCommand.CreatePullRequestOnRemote); } async execute(args?: CreatePullRequestOnRemoteCommandArgs) { @@ -72,7 +72,7 @@ export class CreatePullRequestOnRemoteCommand extends Command { }, }; - void (await executeCommand(Commands.OpenOnRemote, { + void (await executeCommand(GlCommand.OpenOnRemote, { resource: resource, remotes: remotes, })); diff --git a/src/commands/diffFolderWithRevision.ts b/src/commands/diffFolderWithRevision.ts index 15485425ec3b6..3a916f215cdad 100644 --- a/src/commands/diffFolderWithRevision.ts +++ b/src/commands/diffFolderWithRevision.ts @@ -1,7 +1,7 @@ import type { TextDocumentShowOptions, TextEditor } from 'vscode'; import { FileType, Uri, workspace } from 'vscode'; import { GlyphChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { openFolderCompare } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; @@ -25,7 +25,7 @@ export interface DiffFolderWithRevisionCommandArgs { @command() export class DiffFolderWithRevisionCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.DiffFolderWithRevision); + super(GlCommand.DiffFolderWithRevision); } async execute(editor?: TextEditor, uri?: Uri, args?: DiffFolderWithRevisionCommandArgs): Promise { @@ -64,7 +64,7 @@ export class DiffFolderWithRevisionCommand extends ActiveEditorCommand { const pick = await showCommitPicker(log, title, 'Choose a commit to compare with', { picked: gitUri.sha, showOtherReferences: [ - CommandQuickPickItem.fromCommand('Choose a Branch or Tag...', Commands.DiffFolderWithRevisionFrom), + CommandQuickPickItem.fromCommand('Choose a Branch or Tag...', GlCommand.DiffFolderWithRevisionFrom), ], }); if (pick == null) return; diff --git a/src/commands/diffFolderWithRevisionFrom.ts b/src/commands/diffFolderWithRevisionFrom.ts index e10192bf8a2b8..f2cc423d906bb 100644 --- a/src/commands/diffFolderWithRevisionFrom.ts +++ b/src/commands/diffFolderWithRevisionFrom.ts @@ -1,7 +1,7 @@ import type { TextEditor } from 'vscode'; import { FileType, Uri, workspace } from 'vscode'; import { GlyphChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { openFolderCompare } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; @@ -23,7 +23,7 @@ export interface DiffFolderWithRevisionFromCommandArgs { @command() export class DiffFolderWithRevisionFromCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.DiffFolderWithRevisionFrom); + super(GlCommand.DiffFolderWithRevisionFrom); } async execute(editor?: TextEditor, uri?: Uri, args?: DiffFolderWithRevisionFromCommandArgs): Promise { diff --git a/src/commands/diffLineWithPrevious.ts b/src/commands/diffLineWithPrevious.ts index 9e1b20ac1a43e..8892b38fc8051 100644 --- a/src/commands/diffLineWithPrevious.ts +++ b/src/commands/diffLineWithPrevious.ts @@ -1,5 +1,5 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; @@ -20,7 +20,7 @@ export interface DiffLineWithPreviousCommandArgs { @command() export class DiffLineWithPreviousCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.DiffLineWithPrevious); + super(GlCommand.DiffLineWithPrevious); } protected override preExecute(context: CommandContext, args?: DiffLineWithPreviousCommandArgs): Promise { @@ -56,7 +56,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand { return; } - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: diffUris.current.repoPath, lhs: { sha: diffUris.previous.sha ?? '', diff --git a/src/commands/diffLineWithWorking.ts b/src/commands/diffLineWithWorking.ts index 13986797c7f91..55bae2aa588f6 100644 --- a/src/commands/diffLineWithWorking.ts +++ b/src/commands/diffLineWithWorking.ts @@ -1,6 +1,6 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import { window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; @@ -22,7 +22,7 @@ export interface DiffLineWithWorkingCommandArgs { @command() export class DiffLineWithWorkingCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.DiffLineWithWorking); + super(GlCommand.DiffLineWithWorking); } protected override preExecute(context: CommandContext, args?: DiffLineWithWorkingCommandArgs): Promise { @@ -99,7 +99,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand { return; } - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: args.commit.repoPath, lhs: { sha: lhsSha, diff --git a/src/commands/diffWith.ts b/src/commands/diffWith.ts index 998d10bc43298..0a9ba51abc78c 100644 --- a/src/commands/diffWith.ts +++ b/src/commands/diffWith.ts @@ -1,7 +1,7 @@ import type { TextDocumentShowOptions, Uri } from 'vscode'; import { Range, ViewColumn } from 'vscode'; import { GlyphChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import type { GitCommit } from '../git/models/commit'; import { isCommit } from '../git/models/commit'; @@ -13,7 +13,7 @@ import { Logger } from '../system/logger'; import { basename } from '../system/path'; import { command } from '../system/vscode/command'; import { openDiffEditor } from '../system/vscode/utils'; -import { Command } from './base'; +import { GlCommandBase } from './base'; export interface DiffWithCommandArgsRevision { sha: string; @@ -31,7 +31,7 @@ export interface DiffWithCommandArgs { } @command() -export class DiffWithCommand extends Command { +export class DiffWithCommand extends GlCommandBase { static createMarkdownCommandLink(args: DiffWithCommandArgs): string; static createMarkdownCommandLink(commit: GitCommit, line?: number): string; static createMarkdownCommandLink(argsOrCommit: DiffWithCommandArgs | GitCommit, line?: number): string { @@ -75,11 +75,11 @@ export class DiffWithCommand extends Command { args = argsOrCommit; } - return createMarkdownCommandLink(Commands.DiffWith, args); + return createMarkdownCommandLink(GlCommand.DiffWith, args); } constructor(private readonly container: Container) { - super(Commands.DiffWith); + super(GlCommand.DiffWith); } async execute(args?: DiffWithCommandArgs): Promise { diff --git a/src/commands/diffWithNext.ts b/src/commands/diffWithNext.ts index 0637a5744cd11..39311b8e35984 100644 --- a/src/commands/diffWithNext.ts +++ b/src/commands/diffWithNext.ts @@ -1,5 +1,5 @@ import type { Range, TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; @@ -22,11 +22,11 @@ export interface DiffWithNextCommandArgs { @command() export class DiffWithNextCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.DiffWithNext, Commands.DiffWithNextInDiffLeft, Commands.DiffWithNextInDiffRight]); + super([GlCommand.DiffWithNext, GlCommand.DiffWithNextInDiffLeft, GlCommand.DiffWithNextInDiffRight]); } protected override preExecute(context: CommandContext, args?: DiffWithNextCommandArgs) { - if (context.command === Commands.DiffWithNextInDiffLeft) { + if (context.command === GlCommand.DiffWithNextInDiffLeft) { args = { ...args, inDiffLeftEditor: true }; } @@ -54,7 +54,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand { if (diffUris?.next == null) return; - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: diffUris.current.repoPath, lhs: { sha: diffUris.current.sha ?? '', diff --git a/src/commands/diffWithPrevious.ts b/src/commands/diffWithPrevious.ts index 3c7ce70ad4402..52e182edee732 100644 --- a/src/commands/diffWithPrevious.ts +++ b/src/commands/diffWithPrevious.ts @@ -1,5 +1,5 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; @@ -24,11 +24,15 @@ export interface DiffWithPreviousCommandArgs { @command() export class DiffWithPreviousCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.DiffWithPrevious, Commands.DiffWithPreviousInDiffLeft, Commands.DiffWithPreviousInDiffRight]); + super([ + GlCommand.DiffWithPrevious, + GlCommand.DiffWithPreviousInDiffLeft, + GlCommand.DiffWithPreviousInDiffRight, + ]); } protected override preExecute(context: CommandContext, args?: DiffWithPreviousCommandArgs) { - if (context.command === Commands.DiffWithPreviousInDiffRight) { + if (context.command === GlCommand.DiffWithPreviousInDiffRight) { args = { ...args, inDiffRightEditor: true }; } @@ -51,7 +55,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { let gitUri; if (args.commit?.file != null) { if (!args.commit.isUncommitted) { - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: args.commit.repoPath, lhs: { sha: `${args.commit.sha}^`, @@ -116,7 +120,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { ); } - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: diffUris.current.repoPath, lhs: { sha: diffUris.previous.sha ?? '', diff --git a/src/commands/diffWithRevision.ts b/src/commands/diffWithRevision.ts index e7eaafacf38c4..9de6e3f6fc320 100644 --- a/src/commands/diffWithRevision.ts +++ b/src/commands/diffWithRevision.ts @@ -1,6 +1,6 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import { GlyphChars, quickPickTitleMaxChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { shortenRevision } from '../git/models/reference'; @@ -25,7 +25,7 @@ export interface DiffWithRevisionCommandArgs { @command() export class DiffWithRevisionCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.DiffWithRevision); + super(GlCommand.DiffWithRevision); } async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithRevisionCommandArgs): Promise { @@ -77,7 +77,7 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand { description: description, }, undefined, - Commands.DiffWithRevision, + GlCommand.DiffWithRevision, [this.container.git.getAbsoluteUri(f.path, gitUri.repoPath)], ), ); @@ -112,7 +112,7 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand { keyboard: { keys: ['right', 'alt+right', 'ctrl+right'], onDidPressKey: async (_key, item) => { - await executeCommand(Commands.DiffWith, { + await executeCommand(GlCommand.DiffWith, { repoPath: gitUri.repoPath, lhs: { sha: item.item.ref, @@ -130,19 +130,19 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand { showOtherReferences: [ CommandQuickPickItem.fromCommand<[Uri]>( 'Choose a Branch or Tag...', - Commands.DiffWithRevisionFrom, + GlCommand.DiffWithRevisionFrom, [uri], ), CommandQuickPickItem.fromCommand<[Uri, DiffWithRevisionFromCommandArgs]>( 'Choose a Stash...', - Commands.DiffWithRevisionFrom, + GlCommand.DiffWithRevisionFrom, [uri, { stash: true }], ), ], }); if (pick == null) return; - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: gitUri.repoPath, lhs: { sha: pick.ref, diff --git a/src/commands/diffWithRevisionFrom.ts b/src/commands/diffWithRevisionFrom.ts index 7b5111c83493b..41571de6f4780 100644 --- a/src/commands/diffWithRevisionFrom.ts +++ b/src/commands/diffWithRevisionFrom.ts @@ -1,6 +1,6 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import { GlyphChars, quickPickTitleMaxChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { isBranchReference, shortenRevision } from '../git/models/reference'; @@ -22,7 +22,7 @@ export interface DiffWithRevisionFromCommandArgs { @command() export class DiffWithRevisionFromCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.DiffWithRevisionFrom); + super(GlCommand.DiffWithRevisionFrom); } async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithRevisionFromCommandArgs) { @@ -92,7 +92,7 @@ export class DiffWithRevisionFromCommand extends ActiveEditorCommand { } } - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: gitUri.repoPath, lhs: { sha: sha, diff --git a/src/commands/diffWithWorking.ts b/src/commands/diffWithWorking.ts index 4cbab8bf9840b..f3fbeb4553b6f 100644 --- a/src/commands/diffWithWorking.ts +++ b/src/commands/diffWithWorking.ts @@ -1,6 +1,6 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import { window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { deletedOrMissing, uncommittedStaged } from '../git/models/constants'; @@ -24,7 +24,7 @@ export interface DiffWithWorkingCommandArgs { @command() export class DiffWithWorkingCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.DiffWithWorking, Commands.DiffWithWorkingInDiffLeft, Commands.DiffWithWorkingInDiffRight]); + super([GlCommand.DiffWithWorking, GlCommand.DiffWithWorkingInDiffLeft, GlCommand.DiffWithWorkingInDiffRight]); } async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithWorkingCommandArgs): Promise { @@ -78,7 +78,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand { if (gitUri.isUncommittedStaged) { const status = await this.container.git.getStatusForFile(gitUri.repoPath!, gitUri); if (status?.indexStatus != null) { - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: gitUri.repoPath, lhs: { sha: uncommittedStaged, @@ -117,7 +117,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand { workingUri = pickedUri; } - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: gitUri.repoPath, lhs: { sha: gitUri.sha, diff --git a/src/commands/externalDiff.ts b/src/commands/externalDiff.ts index d4742765114a6..91c706258f5ff 100644 --- a/src/commands/externalDiff.ts +++ b/src/commands/externalDiff.ts @@ -2,7 +2,7 @@ import type { SourceControlResourceState } from 'vscode'; import { env, Uri, window } from 'vscode'; import type { ScmResource } from '../@types/vscode.git.resources'; import { ScmResourceGroupType, ScmStatus } from '../@types/vscode.git.resources.enums'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { isUncommitted } from '../git/models/reference'; @@ -13,7 +13,7 @@ import { Logger } from '../system/logger'; import { command } from '../system/vscode/command'; import { configuration } from '../system/vscode/configuration'; import type { CommandContext } from './base'; -import { Command, isCommandContextViewNodeHasFileCommit, isCommandContextViewNodeHasFileRefs } from './base'; +import { GlCommandBase, isCommandContextViewNodeHasFileCommit, isCommandContextViewNodeHasFileRefs } from './base'; interface ExternalDiffFile { uri: Uri; @@ -27,9 +27,9 @@ export interface ExternalDiffCommandArgs { } @command() -export class ExternalDiffCommand extends Command { +export class ExternalDiffCommand extends GlCommandBase { constructor(private readonly container: Container) { - super([Commands.ExternalDiff, Commands.ExternalDiffAll]); + super([GlCommand.ExternalDiff, GlCommand.ExternalDiffAll]); } protected override async preExecute(context: CommandContext, args?: ExternalDiffCommandArgs) { @@ -83,7 +83,7 @@ export class ExternalDiffCommand extends Command { } } - if (context.command === Commands.ExternalDiffAll) { + if (context.command === GlCommand.ExternalDiffAll) { if (args.files == null) { const repository = await getRepositoryOrShowPicker('Open All Changes (difftool)'); if (repository == null) return undefined; diff --git a/src/commands/generateCommitMessage.ts b/src/commands/generateCommitMessage.ts index c2bb4e9eda87a..51089a0b51c1c 100644 --- a/src/commands/generateCommitMessage.ts +++ b/src/commands/generateCommitMessage.ts @@ -1,6 +1,6 @@ import type { TextEditor, Uri } from 'vscode'; import { ProgressLocation, window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { showGenericErrorMessage } from '../messages'; @@ -16,7 +16,7 @@ export interface GenerateCommitMessageCommandArgs { @command() export class GenerateCommitMessageCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.GenerateCommitMessage, Commands.GenerateCommitMessageScm]); + super([GlCommand.GenerateCommitMessage, GlCommand.GenerateCommitMessageScm]); } async execute(editor?: TextEditor, uri?: Uri, args?: GenerateCommitMessageCommandArgs) { diff --git a/src/commands/ghpr/openOrCreateWorktree.ts b/src/commands/ghpr/openOrCreateWorktree.ts index ad5333516165c..ecc6e215d3310 100644 --- a/src/commands/ghpr/openOrCreateWorktree.ts +++ b/src/commands/ghpr/openOrCreateWorktree.ts @@ -1,6 +1,6 @@ import type { Uri } from 'vscode'; import { window } from 'vscode'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import type { Container } from '../../container'; import { create as createWorktree, open as openWorktree } from '../../git/actions/worktree'; import { getLocalBranchByUpstream } from '../../git/models/branch'; @@ -12,7 +12,7 @@ import { parseGitRemoteUrl } from '../../git/parsers/remoteParser'; import { Logger } from '../../system/logger'; import { waitUntilNextTick } from '../../system/promise'; import { command } from '../../system/vscode/command'; -import { Command } from '../base'; +import { GlCommandBase } from '../base'; interface GHPRPullRequestNode { readonly pullRequestModel: GHPRPullRequest; @@ -45,9 +45,9 @@ export interface GHPRPullRequest { } @command() -export class OpenOrCreateWorktreeCommand extends Command { +export class OpenOrCreateWorktreeCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.OpenOrCreateWorktreeForGHPR); + super(GlCommand.OpenOrCreateWorktreeForGHPR); } async execute(...args: [GHPRPullRequestNode | GHPRPullRequest, ...unknown[]]) { diff --git a/src/commands/gitWizard.ts b/src/commands/gitWizard.ts index 3331df19ffcf4..6d27d9b957638 100644 --- a/src/commands/gitWizard.ts +++ b/src/commands/gitWizard.ts @@ -1,4 +1,4 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { command } from '../system/vscode/command'; import type { CommandContext } from './base'; @@ -49,41 +49,41 @@ export type GitWizardCommandArgs = export class GitWizardCommand extends QuickWizardCommandBase { constructor(container: Container) { super(container, [ - Commands.GitCommands, - Commands.GitCommandsBranch, - Commands.GitCommandsBranchCreate, - Commands.GitCommandsBranchDelete, - Commands.GitCommandsBranchPrune, - Commands.GitCommandsBranchRename, - Commands.GitCommandsCheckout, - Commands.GitCommandsCherryPick, - Commands.GitCommandsHistory, - Commands.GitCommandsMerge, - Commands.GitCommandsRebase, - Commands.GitCommandsRemote, - Commands.GitCommandsRemoteAdd, - Commands.GitCommandsRemotePrune, - Commands.GitCommandsRemoteRemove, - Commands.GitCommandsReset, - Commands.GitCommandsRevert, - Commands.GitCommandsShow, - Commands.GitCommandsStash, - Commands.GitCommandsStashDrop, - Commands.GitCommandsStashList, - Commands.GitCommandsStashPop, - Commands.GitCommandsStashPush, - Commands.GitCommandsStashRename, - Commands.GitCommandsStatus, - Commands.GitCommandsSwitch, - Commands.GitCommandsTag, - Commands.GitCommandsTagCreate, - Commands.GitCommandsTagDelete, - Commands.GitCommandsWorktree, - Commands.GitCommandsWorktreeCreate, - Commands.GitCommandsWorktreeDelete, - Commands.GitCommandsWorktreeOpen, + GlCommand.GitCommands, + GlCommand.GitCommandsBranch, + GlCommand.GitCommandsBranchCreate, + GlCommand.GitCommandsBranchDelete, + GlCommand.GitCommandsBranchPrune, + GlCommand.GitCommandsBranchRename, + GlCommand.GitCommandsCheckout, + GlCommand.GitCommandsCherryPick, + GlCommand.GitCommandsHistory, + GlCommand.GitCommandsMerge, + GlCommand.GitCommandsRebase, + GlCommand.GitCommandsRemote, + GlCommand.GitCommandsRemoteAdd, + GlCommand.GitCommandsRemotePrune, + GlCommand.GitCommandsRemoteRemove, + GlCommand.GitCommandsReset, + GlCommand.GitCommandsRevert, + GlCommand.GitCommandsShow, + GlCommand.GitCommandsStash, + GlCommand.GitCommandsStashDrop, + GlCommand.GitCommandsStashList, + GlCommand.GitCommandsStashPop, + GlCommand.GitCommandsStashPush, + GlCommand.GitCommandsStashRename, + GlCommand.GitCommandsStatus, + GlCommand.GitCommandsSwitch, + GlCommand.GitCommandsTag, + GlCommand.GitCommandsTagCreate, + GlCommand.GitCommandsTagDelete, + GlCommand.GitCommandsWorktree, + GlCommand.GitCommandsWorktreeCreate, + GlCommand.GitCommandsWorktreeDelete, + GlCommand.GitCommandsWorktreeOpen, - Commands.CopyWorkingChangesToWorktree, + GlCommand.CopyWorkingChangesToWorktree, ]); } @@ -92,71 +92,71 @@ export class GitWizardCommand extends QuickWizardCommandBase { args?: QuickWizardCommandArgsWithCompletion, ) { switch (context.command) { - case Commands.GitCommandsBranch: + case GlCommand.GitCommandsBranch: return this.execute({ command: 'branch', ...args }); - case Commands.GitCommandsBranchCreate: + case GlCommand.GitCommandsBranchCreate: return this.execute({ command: 'branch', state: { subcommand: 'create' } }); - case Commands.GitCommandsBranchDelete: + case GlCommand.GitCommandsBranchDelete: return this.execute({ command: 'branch', state: { subcommand: 'delete' } }); - case Commands.GitCommandsBranchPrune: + case GlCommand.GitCommandsBranchPrune: return this.execute({ command: 'branch', state: { subcommand: 'prune' } }); - case Commands.GitCommandsBranchRename: + case GlCommand.GitCommandsBranchRename: return this.execute({ command: 'branch', state: { subcommand: 'rename' } }); - case Commands.GitCommandsCherryPick: + case GlCommand.GitCommandsCherryPick: return this.execute({ command: 'cherry-pick' }); - case Commands.GitCommandsHistory: + case GlCommand.GitCommandsHistory: return this.execute({ command: 'log' }); - case Commands.GitCommandsMerge: + case GlCommand.GitCommandsMerge: return this.execute({ command: 'merge' }); - case Commands.GitCommandsRebase: + case GlCommand.GitCommandsRebase: return this.execute({ command: 'rebase' }); - case Commands.GitCommandsRemote: + case GlCommand.GitCommandsRemote: return this.execute({ command: 'remote' }); - case Commands.GitCommandsRemoteAdd: + case GlCommand.GitCommandsRemoteAdd: return this.execute({ command: 'remote', state: { subcommand: 'add' } }); - case Commands.GitCommandsRemotePrune: + case GlCommand.GitCommandsRemotePrune: return this.execute({ command: 'remote', state: { subcommand: 'prune' } }); - case Commands.GitCommandsRemoteRemove: + case GlCommand.GitCommandsRemoteRemove: return this.execute({ command: 'remote', state: { subcommand: 'remove' } }); - case Commands.GitCommandsReset: + case GlCommand.GitCommandsReset: return this.execute({ command: 'reset' }); - case Commands.GitCommandsRevert: + case GlCommand.GitCommandsRevert: return this.execute({ command: 'revert' }); - case Commands.GitCommandsShow: + case GlCommand.GitCommandsShow: return this.execute({ command: 'show' }); - case Commands.GitCommandsStash: + case GlCommand.GitCommandsStash: return this.execute({ command: 'stash' }); - case Commands.GitCommandsStashDrop: + case GlCommand.GitCommandsStashDrop: return this.execute({ command: 'stash', state: { subcommand: 'drop' } }); - case Commands.GitCommandsStashList: + case GlCommand.GitCommandsStashList: return this.execute({ command: 'stash', state: { subcommand: 'list' } }); - case Commands.GitCommandsStashPop: + case GlCommand.GitCommandsStashPop: return this.execute({ command: 'stash', state: { subcommand: 'pop' } }); - case Commands.GitCommandsStashPush: + case GlCommand.GitCommandsStashPush: return this.execute({ command: 'stash', state: { subcommand: 'push' } }); - case Commands.GitCommandsStashRename: + case GlCommand.GitCommandsStashRename: return this.execute({ command: 'stash', state: { subcommand: 'rename' } }); - case Commands.GitCommandsStatus: + case GlCommand.GitCommandsStatus: return this.execute({ command: 'status' }); - case Commands.GitCommandsSwitch: - case Commands.GitCommandsCheckout: + case GlCommand.GitCommandsSwitch: + case GlCommand.GitCommandsCheckout: return this.execute({ command: 'switch' }); - case Commands.GitCommandsTag: + case GlCommand.GitCommandsTag: return this.execute({ command: 'tag' }); - case Commands.GitCommandsTagCreate: + case GlCommand.GitCommandsTagCreate: return this.execute({ command: 'tag', state: { subcommand: 'create' } }); - case Commands.GitCommandsTagDelete: + case GlCommand.GitCommandsTagDelete: return this.execute({ command: 'tag', state: { subcommand: 'delete' } }); - case Commands.GitCommandsWorktree: + case GlCommand.GitCommandsWorktree: return this.execute({ command: 'worktree' }); - case Commands.GitCommandsWorktreeCreate: + case GlCommand.GitCommandsWorktreeCreate: return this.execute({ command: 'worktree', state: { subcommand: 'create' } }); - case Commands.GitCommandsWorktreeDelete: + case GlCommand.GitCommandsWorktreeDelete: return this.execute({ command: 'worktree', state: { subcommand: 'delete' } }); - case Commands.GitCommandsWorktreeOpen: + case GlCommand.GitCommandsWorktreeOpen: return this.execute({ command: 'worktree', state: { subcommand: 'open' } }); - case Commands.CopyWorkingChangesToWorktree: + case GlCommand.CopyWorkingChangesToWorktree: return this.execute({ command: 'worktree', state: { subcommand: 'copy-changes', changes: { type: 'working-tree' } }, diff --git a/src/commands/inspect.ts b/src/commands/inspect.ts index c0e4b585369ec..2adb7789a8228 100644 --- a/src/commands/inspect.ts +++ b/src/commands/inspect.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { showDetailsView } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; @@ -29,11 +29,11 @@ export class InspectCommand extends ActiveEditorCommand { typeof argsOrSha === 'string' ? { ref: createReference(argsOrSha, repoPath!, { refType: 'revision' }), repoPath: repoPath } : argsOrSha; - return createMarkdownCommandLink(Commands.ShowCommitInView, args); + return createMarkdownCommandLink(GlCommand.ShowCommitInView, args); } constructor(private readonly container: Container) { - super([Commands.ShowCommitInView, Commands.ShowInDetailsView, Commands.ShowLineCommitInView]); + super([GlCommand.ShowCommitInView, GlCommand.ShowInDetailsView, GlCommand.ShowLineCommitInView]); } protected override preExecute(context: CommandContext, args?: InspectCommandArgs) { diff --git a/src/commands/inviteToLiveShare.ts b/src/commands/inviteToLiveShare.ts index 74adc115881ae..76b53f3fe424f 100644 --- a/src/commands/inviteToLiveShare.ts +++ b/src/commands/inviteToLiveShare.ts @@ -1,26 +1,26 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { createMarkdownCommandLink } from '../system/commands'; import { command } from '../system/vscode/command'; import type { CommandContext } from './base'; -import { Command, isCommandContextViewNodeHasContributor } from './base'; +import { GlCommandBase, isCommandContextViewNodeHasContributor } from './base'; export interface InviteToLiveShareCommandArgs { email?: string; } @command() -export class InviteToLiveShareCommand extends Command { +export class InviteToLiveShareCommand extends GlCommandBase { static createMarkdownCommandLink(args: InviteToLiveShareCommandArgs): string; static createMarkdownCommandLink(email: string | undefined): string; static createMarkdownCommandLink(argsOrEmail: InviteToLiveShareCommandArgs | string | undefined): string { const args = argsOrEmail === undefined || typeof argsOrEmail === 'string' ? { email: argsOrEmail } : argsOrEmail; - return createMarkdownCommandLink(Commands.InviteToLiveShare, args); + return createMarkdownCommandLink(GlCommand.InviteToLiveShare, args); } constructor(private readonly container: Container) { - super(Commands.InviteToLiveShare); + super(GlCommand.InviteToLiveShare); } protected override preExecute(context: CommandContext, args?: InviteToLiveShareCommandArgs) { diff --git a/src/commands/logging.ts b/src/commands/logging.ts index 1e1759825e16b..13a1b3ef0ec55 100644 --- a/src/commands/logging.ts +++ b/src/commands/logging.ts @@ -1,13 +1,13 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { command } from '../system/vscode/command'; import { configuration } from '../system/vscode/configuration'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class EnableDebugLoggingCommand extends Command { +export class EnableDebugLoggingCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.EnableDebugLogging); + super(GlCommand.EnableDebugLogging); } async execute() { @@ -16,9 +16,9 @@ export class EnableDebugLoggingCommand extends Command { } @command() -export class DisableDebugLoggingCommand extends Command { +export class DisableDebugLoggingCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.DisableDebugLogging); + super(GlCommand.DisableDebugLogging); } async execute() { diff --git a/src/commands/openAssociatedPullRequestOnRemote.ts b/src/commands/openAssociatedPullRequestOnRemote.ts index 22b9f5ba3cc1a..99db5080a3606 100644 --- a/src/commands/openAssociatedPullRequestOnRemote.ts +++ b/src/commands/openAssociatedPullRequestOnRemote.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; @@ -11,7 +11,7 @@ import type { OpenPullRequestOnRemoteCommandArgs } from './openPullRequestOnRemo @command() export class OpenAssociatedPullRequestOnRemoteCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.OpenAssociatedPullRequestOnRemote); + super(GlCommand.OpenAssociatedPullRequestOnRemote); } async execute(editor?: TextEditor, uri?: Uri) { @@ -53,6 +53,6 @@ export class OpenAssociatedPullRequestOnRemoteCommand extends ActiveEditorComman } } - await executeCommand(Commands.OpenPullRequestOnRemote, args); + await executeCommand(GlCommand.OpenPullRequestOnRemote, args); } } diff --git a/src/commands/openBranchOnRemote.ts b/src/commands/openBranchOnRemote.ts index a23582b4c66b6..9e0f266958be4 100644 --- a/src/commands/openBranchOnRemote.ts +++ b/src/commands/openBranchOnRemote.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../git/models/branch'; @@ -23,7 +23,7 @@ export interface OpenBranchOnRemoteCommandArgs { @command() export class OpenBranchOnRemoteCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.OpenBranchOnRemote, Commands.Deprecated_OpenBranchInRemote, Commands.CopyRemoteBranchUrl]); + super([GlCommand.OpenBranchOnRemote, GlCommand.Deprecated_OpenBranchInRemote, GlCommand.CopyRemoteBranchUrl]); } protected override preExecute(context: CommandContext, args?: OpenBranchOnRemoteCommandArgs) { @@ -35,7 +35,7 @@ export class OpenBranchOnRemoteCommand extends ActiveEditorCommand { }; } - if (context.command === Commands.CopyRemoteBranchUrl) { + if (context.command === GlCommand.CopyRemoteBranchUrl) { args = { ...args, clipboard: true }; } @@ -87,7 +87,7 @@ export class OpenBranchOnRemoteCommand extends ActiveEditorCommand { } } - void (await executeCommand(Commands.OpenOnRemote, { + void (await executeCommand(GlCommand.OpenOnRemote, { resource: { type: RemoteResourceType.Branch, branch: args.branch || 'HEAD', diff --git a/src/commands/openBranchesOnRemote.ts b/src/commands/openBranchesOnRemote.ts index 39894df3606bf..1d7fce3180583 100644 --- a/src/commands/openBranchesOnRemote.ts +++ b/src/commands/openBranchesOnRemote.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { RemoteResourceType } from '../git/models/remoteResource'; @@ -20,9 +20,9 @@ export interface OpenBranchesOnRemoteCommandArgs { export class OpenBranchesOnRemoteCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { super([ - Commands.OpenBranchesOnRemote, - Commands.Deprecated_OpenBranchesInRemote, - Commands.CopyRemoteBranchesUrl, + GlCommand.OpenBranchesOnRemote, + GlCommand.Deprecated_OpenBranchesInRemote, + GlCommand.CopyRemoteBranchesUrl, ]); } @@ -31,7 +31,7 @@ export class OpenBranchesOnRemoteCommand extends ActiveEditorCommand { args = { ...args, remote: context.node.remote.name }; } - if (context.command === Commands.CopyRemoteBranchesUrl) { + if (context.command === GlCommand.CopyRemoteBranchesUrl) { args = { ...args, clipboard: true }; } @@ -53,7 +53,7 @@ export class OpenBranchesOnRemoteCommand extends ActiveEditorCommand { if (!repoPath) return; try { - void (await executeCommand(Commands.OpenOnRemote, { + void (await executeCommand(GlCommand.OpenOnRemote, { resource: { type: RemoteResourceType.Branches, }, diff --git a/src/commands/openChangedFiles.ts b/src/commands/openChangedFiles.ts index b85df44be40e6..3c378c106a37b 100644 --- a/src/commands/openChangedFiles.ts +++ b/src/commands/openChangedFiles.ts @@ -1,6 +1,6 @@ import type { Uri } from 'vscode'; import { window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { showGenericErrorMessage } from '../messages'; import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; @@ -8,16 +8,16 @@ import { filterMap } from '../system/array'; import { Logger } from '../system/logger'; import { command } from '../system/vscode/command'; import { findOrOpenEditors } from '../system/vscode/utils'; -import { Command } from './base'; +import { GlCommandBase } from './base'; export interface OpenChangedFilesCommandArgs { uris?: Uri[]; } @command() -export class OpenChangedFilesCommand extends Command { +export class OpenChangedFilesCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.OpenChangedFiles); + super(GlCommand.OpenChangedFiles); } async execute(args?: OpenChangedFilesCommandArgs) { diff --git a/src/commands/openCommitOnRemote.ts b/src/commands/openCommitOnRemote.ts index 42c14ef5efe4d..eb4f3c593a2b6 100644 --- a/src/commands/openCommitOnRemote.ts +++ b/src/commands/openCommitOnRemote.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { deletedOrMissing } from '../git/models/constants'; @@ -35,11 +35,11 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand { static createMarkdownCommandLink(args: OpenCommitOnRemoteCommandArgs): string; static createMarkdownCommandLink(argsOrSha: OpenCommitOnRemoteCommandArgs | string): string { const args: OpenCommitOnRemoteCommandArgs = typeof argsOrSha === 'string' ? { sha: argsOrSha } : argsOrSha; - return createMarkdownCommandLink(Commands.OpenCommitOnRemote, args); + return createMarkdownCommandLink(GlCommand.OpenCommitOnRemote, args); } constructor(private readonly container: Container) { - super([Commands.OpenCommitOnRemote, Commands.Deprecated_OpenCommitInRemote, Commands.CopyRemoteCommitUrl]); + super([GlCommand.OpenCommitOnRemote, GlCommand.Deprecated_OpenCommitInRemote, GlCommand.CopyRemoteCommitUrl]); } protected override preExecute(context: CommandContext, args?: OpenCommitOnRemoteCommandArgs) { @@ -61,7 +61,7 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand { uri = context.uri; } - if (context.command === Commands.CopyRemoteCommitUrl) { + if (context.command === GlCommand.CopyRemoteCommitUrl) { args = { ...args, clipboard: true }; } @@ -120,7 +120,7 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand { return; } - void (await executeCommand(Commands.OpenOnRemote, { + void (await executeCommand(GlCommand.OpenOnRemote, { resource: { type: RemoteResourceType.Commit, sha: args.sha, diff --git a/src/commands/openComparisonOnRemote.ts b/src/commands/openComparisonOnRemote.ts index 16aa7c48df276..8cc46465638c4 100644 --- a/src/commands/openComparisonOnRemote.ts +++ b/src/commands/openComparisonOnRemote.ts @@ -1,11 +1,11 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { RemoteResourceType } from '../git/models/remoteResource'; import { showGenericErrorMessage } from '../messages'; import { Logger } from '../system/logger'; import { command, executeCommand } from '../system/vscode/command'; import type { CommandContext } from './base'; -import { Command } from './base'; +import { GlCommandBase } from './base'; import type { OpenOnRemoteCommandArgs } from './openOnRemote'; export interface OpenComparisonOnRemoteCommandArgs { @@ -17,9 +17,9 @@ export interface OpenComparisonOnRemoteCommandArgs { } @command() -export class OpenComparisonOnRemoteCommand extends Command { +export class OpenComparisonOnRemoteCommand extends GlCommandBase { constructor(private readonly container: Container) { - super([Commands.OpenComparisonOnRemote, Commands.CopyRemoteComparisonUrl]); + super([GlCommand.OpenComparisonOnRemote, GlCommand.CopyRemoteComparisonUrl]); } protected override preExecute(context: CommandContext, args?: OpenComparisonOnRemoteCommandArgs) { @@ -48,7 +48,7 @@ export class OpenComparisonOnRemoteCommand extends Command { } } - if (context.command === Commands.CopyRemoteComparisonUrl) { + if (context.command === GlCommand.CopyRemoteComparisonUrl) { args = { ...args, clipboard: true }; } @@ -59,7 +59,7 @@ export class OpenComparisonOnRemoteCommand extends Command { if (args?.repoPath == null || args.ref1 == null || args.ref2 == null) return; try { - void (await executeCommand(Commands.OpenOnRemote, { + void (await executeCommand(GlCommand.OpenOnRemote, { resource: { type: RemoteResourceType.Comparison, base: args.ref1, diff --git a/src/commands/openCurrentBranchOnRemote.ts b/src/commands/openCurrentBranchOnRemote.ts index dfcbffc3b4e0a..87a3e7a6213bb 100644 --- a/src/commands/openCurrentBranchOnRemote.ts +++ b/src/commands/openCurrentBranchOnRemote.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../git/models/branch'; @@ -14,7 +14,7 @@ import type { OpenOnRemoteCommandArgs } from './openOnRemote'; @command() export class OpenCurrentBranchOnRemoteCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.OpenCurrentBranchOnRemote); + super(GlCommand.OpenCurrentBranchOnRemote); } async execute(editor?: TextEditor, uri?: Uri) { @@ -28,7 +28,7 @@ export class OpenCurrentBranchOnRemoteCommand extends ActiveEditorCommand { try { const branch = await repository.git.getBranch(); if (branch?.detached) { - void (await executeCommand(Commands.OpenOnRemote, { + void (await executeCommand(GlCommand.OpenOnRemote, { resource: { type: RemoteResourceType.Commit, sha: branch.sha ?? 'HEAD', @@ -48,7 +48,7 @@ export class OpenCurrentBranchOnRemoteCommand extends ActiveEditorCommand { branchName = branch.name; } - void (await executeCommand(Commands.OpenOnRemote, { + void (await executeCommand(GlCommand.OpenOnRemote, { resource: { type: RemoteResourceType.Branch, branch: branchName ?? 'HEAD', diff --git a/src/commands/openDirectoryCompare.ts b/src/commands/openDirectoryCompare.ts index 5cf97d388e32f..e9faecc84c734 100644 --- a/src/commands/openDirectoryCompare.ts +++ b/src/commands/openDirectoryCompare.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { openDirectoryCompare } from '../git/actions/commit'; import { showGenericErrorMessage } from '../messages'; @@ -20,29 +20,29 @@ export interface OpenDirectoryCompareCommandArgs { export class OpenDirectoryCompareCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { super([ - Commands.DiffDirectory, - Commands.DiffDirectoryWithHead, - Commands.ViewsOpenDirectoryDiff, - Commands.ViewsOpenDirectoryDiffWithWorking, + GlCommand.DiffDirectory, + GlCommand.DiffDirectoryWithHead, + GlCommand.ViewsOpenDirectoryDiff, + GlCommand.ViewsOpenDirectoryDiffWithWorking, ]); } protected override async preExecute(context: CommandContext, args?: OpenDirectoryCompareCommandArgs) { switch (context.command) { - case Commands.DiffDirectoryWithHead: + case GlCommand.DiffDirectoryWithHead: args = { ...args }; args.ref1 = 'HEAD'; args.ref2 = undefined; break; - case Commands.ViewsOpenDirectoryDiff: + case GlCommand.ViewsOpenDirectoryDiff: if (context.type === 'viewItem' && context.node instanceof CompareResultsNode) { args = { ...args }; [args.ref1, args.ref2] = await context.node.getDiffRefs(); } break; - case Commands.ViewsOpenDirectoryDiffWithWorking: + case GlCommand.ViewsOpenDirectoryDiffWithWorking: if (isCommandContextViewNodeHasRef(context)) { args = { ...args }; args.ref1 = context.node.ref.ref; diff --git a/src/commands/openFileAtRevision.ts b/src/commands/openFileAtRevision.ts index af275f16232b1..6187fcbf4738d 100644 --- a/src/commands/openFileAtRevision.ts +++ b/src/commands/openFileAtRevision.ts @@ -2,7 +2,7 @@ import type { TextDocumentShowOptions, TextEditor } from 'vscode'; import { Uri } from 'vscode'; import type { FileAnnotationType } from '../config'; import { GlyphChars, quickPickTitleMaxChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { openFileAtRevision } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; @@ -51,15 +51,15 @@ export class OpenFileAtRevisionCommand extends ActiveEditorCommand { args = argsOrUri; } - return createMarkdownCommandLink(Commands.OpenFileAtRevision, args); + return createMarkdownCommandLink(GlCommand.OpenFileAtRevision, args); } constructor(private readonly container: Container) { - super([Commands.OpenFileAtRevision, Commands.OpenBlamePriorToChange]); + super([GlCommand.OpenFileAtRevision, GlCommand.OpenBlamePriorToChange]); } protected override async preExecute(context: CommandContext, args?: OpenFileAtRevisionCommandArgs) { - if (context.command === Commands.OpenBlamePriorToChange) { + if (context.command === GlCommand.OpenBlamePriorToChange) { args = { ...args, annotationType: 'blame' }; if (args.revisionUri == null && context.editor != null) { const editorLine = context.editor.selection.active.line; @@ -159,7 +159,7 @@ export class OpenFileAtRevisionCommand extends ActiveEditorCommand { description: description, }, undefined, - Commands.OpenFileAtRevision, + GlCommand.OpenFileAtRevision, [this.container.git.getAbsoluteUri(f.path, gitUri.repoPath)], ), ); @@ -205,12 +205,12 @@ export class OpenFileAtRevisionCommand extends ActiveEditorCommand { showOtherReferences: [ CommandQuickPickItem.fromCommand<[Uri]>( 'Choose a Branch or Tag...', - Commands.OpenFileAtRevisionFrom, + GlCommand.OpenFileAtRevisionFrom, [uri], ), CommandQuickPickItem.fromCommand<[Uri, OpenFileAtRevisionFromCommandArgs]>( 'Choose a Stash...', - Commands.OpenFileAtRevisionFrom, + GlCommand.OpenFileAtRevisionFrom, [uri, { stash: true }], ), ], diff --git a/src/commands/openFileAtRevisionFrom.ts b/src/commands/openFileAtRevisionFrom.ts index 463fcdef426db..95534842baa98 100644 --- a/src/commands/openFileAtRevisionFrom.ts +++ b/src/commands/openFileAtRevisionFrom.ts @@ -1,7 +1,7 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import type { FileAnnotationType } from '../config'; import { GlyphChars, quickPickTitleMaxChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { openFileAtRevision } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; @@ -25,7 +25,7 @@ export interface OpenFileAtRevisionFromCommandArgs { @command() export class OpenFileAtRevisionFromCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.OpenFileAtRevisionFrom); + super(GlCommand.OpenFileAtRevisionFrom); } async execute(editor: TextEditor | undefined, uri?: Uri, args?: OpenFileAtRevisionFromCommandArgs) { diff --git a/src/commands/openFileFromRemote.ts b/src/commands/openFileFromRemote.ts index fc4b18fc81df0..0fc643b540f32 100644 --- a/src/commands/openFileFromRemote.ts +++ b/src/commands/openFileFromRemote.ts @@ -1,14 +1,14 @@ import { env, Range, Uri, window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { command } from '../system/vscode/command'; import { openEditor } from '../system/vscode/utils'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class OpenFileFromRemoteCommand extends Command { +export class OpenFileFromRemoteCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.OpenFileFromRemote); + super(GlCommand.OpenFileFromRemote); } async execute() { diff --git a/src/commands/openFileOnRemote.ts b/src/commands/openFileOnRemote.ts index b8b8a4b07546a..643e3a9f3faf1 100644 --- a/src/commands/openFileOnRemote.ts +++ b/src/commands/openFileOnRemote.ts @@ -1,7 +1,7 @@ import type { TextEditor, Uri } from 'vscode'; import { Range } from 'vscode'; import { GlyphChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../git/models/branch'; @@ -36,12 +36,12 @@ export interface OpenFileOnRemoteCommandArgs { export class OpenFileOnRemoteCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { super([ - Commands.OpenFileOnRemote, - Commands.Deprecated_OpenFileInRemote, - Commands.CopyRemoteFileUrl, - Commands.CopyRemoteFileUrlWithoutRange, - Commands.OpenFileOnRemoteFrom, - Commands.CopyRemoteFileUrlFrom, + GlCommand.OpenFileOnRemote, + GlCommand.Deprecated_OpenFileInRemote, + GlCommand.CopyRemoteFileUrl, + GlCommand.CopyRemoteFileUrlWithoutRange, + GlCommand.OpenFileOnRemoteFrom, + GlCommand.CopyRemoteFileUrlFrom, ]); } @@ -52,7 +52,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { args = { ...args, line: context.line, range: true }; } - if (context.command === Commands.CopyRemoteFileUrlWithoutRange) { + if (context.command === GlCommand.CopyRemoteFileUrlWithoutRange) { args = { ...args, range: false }; } @@ -60,9 +60,9 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { args = { ...args, range: false }; if ( - context.command === Commands.CopyRemoteFileUrl || - context.command === Commands.CopyRemoteFileUrlWithoutRange || - context.command === Commands.CopyRemoteFileUrlFrom + context.command === GlCommand.CopyRemoteFileUrl || + context.command === GlCommand.CopyRemoteFileUrlWithoutRange || + context.command === GlCommand.CopyRemoteFileUrlFrom ) { // If it is a StatusFileNode then don't include the sha, since it hasn't been pushed yet args.sha = context.node instanceof StatusFileNode ? undefined : context.node.commit.sha; @@ -78,9 +78,9 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { } if ( - context.command === Commands.CopyRemoteFileUrl || - context.command === Commands.CopyRemoteFileUrlWithoutRange || - context.command === Commands.CopyRemoteFileUrlFrom + context.command === GlCommand.CopyRemoteFileUrl || + context.command === GlCommand.CopyRemoteFileUrlWithoutRange || + context.command === GlCommand.CopyRemoteFileUrlFrom ) { args = { ...args, clipboard: true }; if (args.sha == null) { @@ -104,7 +104,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { } } - if (context.command === Commands.OpenFileOnRemoteFrom || context.command === Commands.CopyRemoteFileUrlFrom) { + if (context.command === GlCommand.OpenFileOnRemoteFrom || context.command === GlCommand.CopyRemoteFileUrlFrom) { args = { ...args, pickBranchOrTag: true, range: false }; // Override range since it can be wrong at a different commit } @@ -207,7 +207,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { } } - void (await executeCommand(Commands.OpenOnRemote, { + void (await executeCommand(GlCommand.OpenOnRemote, { resource: { type: sha == null ? RemoteResourceType.File : RemoteResourceType.Revision, branchOrTag: args.branchOrTag ?? 'HEAD', diff --git a/src/commands/openOnRemote.ts b/src/commands/openOnRemote.ts index dc05a35daa54b..fd376f2b60319 100644 --- a/src/commands/openOnRemote.ts +++ b/src/commands/openOnRemote.ts @@ -1,5 +1,5 @@ import { GlyphChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { createRevisionRange, shortenRevision } from '../git/models/reference'; import type { GitRemote } from '../git/models/remote'; @@ -13,7 +13,7 @@ import { ensureArray } from '../system/array'; import { Logger } from '../system/logger'; import { pad, splitSingle } from '../system/string'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; export type OpenOnRemoteCommandArgs = | { @@ -32,9 +32,9 @@ export type OpenOnRemoteCommandArgs = }; @command() -export class OpenOnRemoteCommand extends Command { +export class OpenOnRemoteCommand extends GlCommandBase { constructor(private readonly container: Container) { - super([Commands.OpenOnRemote, Commands.Deprecated_OpenInRemote]); + super([GlCommand.OpenOnRemote, GlCommand.Deprecated_OpenInRemote]); } async execute(args?: OpenOnRemoteCommandArgs) { diff --git a/src/commands/openOnlyChangedFiles.ts b/src/commands/openOnlyChangedFiles.ts index 37e703ea41441..0194c7bc53208 100644 --- a/src/commands/openOnlyChangedFiles.ts +++ b/src/commands/openOnlyChangedFiles.ts @@ -1,6 +1,6 @@ import type { Uri } from 'vscode'; import { TabInputCustom, TabInputNotebook, TabInputNotebookDiff, TabInputText, TabInputTextDiff, window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { showGenericErrorMessage } from '../messages'; import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; @@ -9,16 +9,16 @@ import { UriComparer } from '../system/comparers'; import { Logger } from '../system/logger'; import { command } from '../system/vscode/command'; import { findOrOpenEditors } from '../system/vscode/utils'; -import { Command } from './base'; +import { GlCommandBase } from './base'; export interface OpenOnlyChangedFilesCommandArgs { uris?: Uri[]; } @command() -export class OpenOnlyChangedFilesCommand extends Command { +export class OpenOnlyChangedFilesCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.OpenOnlyChangedFiles); + super(GlCommand.OpenOnlyChangedFiles); } async execute(args?: OpenOnlyChangedFilesCommandArgs) { diff --git a/src/commands/openPullRequestOnRemote.ts b/src/commands/openPullRequestOnRemote.ts index 173e5abb79d71..8e9f3d7d2e466 100644 --- a/src/commands/openPullRequestOnRemote.ts +++ b/src/commands/openPullRequestOnRemote.ts @@ -1,11 +1,11 @@ import { env, window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { shortenRevision } from '../git/models/reference'; import { command } from '../system/vscode/command'; import { openUrl } from '../system/vscode/utils'; import type { CommandContext } from './base'; -import { Command } from './base'; +import { GlCommandBase } from './base'; export interface OpenPullRequestOnRemoteCommandArgs { clipboard?: boolean; @@ -15,9 +15,9 @@ export interface OpenPullRequestOnRemoteCommandArgs { } @command() -export class OpenPullRequestOnRemoteCommand extends Command { +export class OpenPullRequestOnRemoteCommand extends GlCommandBase { constructor(private readonly container: Container) { - super([Commands.OpenPullRequestOnRemote, Commands.CopyRemotePullRequestUrl]); + super([GlCommand.OpenPullRequestOnRemote, GlCommand.CopyRemotePullRequestUrl]); } protected override preExecute(context: CommandContext, args?: OpenPullRequestOnRemoteCommandArgs) { @@ -25,7 +25,7 @@ export class OpenPullRequestOnRemoteCommand extends Command { args = { ...args, pr: context.node.pullRequest != null ? { url: context.node.pullRequest.url } : undefined, - clipboard: context.command === Commands.CopyRemotePullRequestUrl, + clipboard: context.command === GlCommand.CopyRemotePullRequestUrl, }; } diff --git a/src/commands/openRepoOnRemote.ts b/src/commands/openRepoOnRemote.ts index b40382af95cc4..b8e8b86a2835c 100644 --- a/src/commands/openRepoOnRemote.ts +++ b/src/commands/openRepoOnRemote.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { RemoteResourceType } from '../git/models/remoteResource'; @@ -19,7 +19,7 @@ export interface OpenRepoOnRemoteCommandArgs { @command() export class OpenRepoOnRemoteCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.OpenRepoOnRemote, Commands.Deprecated_OpenRepoInRemote, Commands.CopyRemoteRepositoryUrl]); + super([GlCommand.OpenRepoOnRemote, GlCommand.Deprecated_OpenRepoInRemote, GlCommand.CopyRemoteRepositoryUrl]); } protected override preExecute(context: CommandContext, args?: OpenRepoOnRemoteCommandArgs) { @@ -27,7 +27,7 @@ export class OpenRepoOnRemoteCommand extends ActiveEditorCommand { args = { ...args, remote: context.node.remote.name }; } - if (context.command === Commands.CopyRemoteRepositoryUrl) { + if (context.command === GlCommand.CopyRemoteRepositoryUrl) { args = { ...args, clipboard: true }; } @@ -51,7 +51,7 @@ export class OpenRepoOnRemoteCommand extends ActiveEditorCommand { if (!repoPath) return; try { - void (await executeCommand(Commands.OpenOnRemote, { + void (await executeCommand(GlCommand.OpenOnRemote, { resource: { type: RemoteResourceType.Repo, }, diff --git a/src/commands/openRevisionFile.ts b/src/commands/openRevisionFile.ts index 7c59ae0216451..8df7421284643 100644 --- a/src/commands/openRevisionFile.ts +++ b/src/commands/openRevisionFile.ts @@ -1,6 +1,6 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import type { FileAnnotationType } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { openFileAtRevision } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; @@ -21,7 +21,11 @@ export interface OpenRevisionFileCommandArgs { @command() export class OpenRevisionFileCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.OpenRevisionFile, Commands.OpenRevisionFileInDiffLeft, Commands.OpenRevisionFileInDiffRight]); + super([ + GlCommand.OpenRevisionFile, + GlCommand.OpenRevisionFileInDiffLeft, + GlCommand.OpenRevisionFileInDiffRight, + ]); } async execute(editor?: TextEditor, uri?: Uri, args?: OpenRevisionFileCommandArgs) { diff --git a/src/commands/openWorkingFile.ts b/src/commands/openWorkingFile.ts index 6bdfa8022a30e..6a21829baa1b7 100644 --- a/src/commands/openWorkingFile.ts +++ b/src/commands/openWorkingFile.ts @@ -1,7 +1,7 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import { Range, window } from 'vscode'; import type { FileAnnotationType } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri, isGitUri } from '../git/gitUri'; import { showGenericErrorMessage } from '../messages'; @@ -20,7 +20,7 @@ export interface OpenWorkingFileCommandArgs { @command() export class OpenWorkingFileCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.OpenWorkingFile, Commands.OpenWorkingFileInDiffLeft, Commands.OpenWorkingFileInDiffRight]); + super([GlCommand.OpenWorkingFile, GlCommand.OpenWorkingFileInDiffLeft, GlCommand.OpenWorkingFileInDiffRight]); } async execute(editor: TextEditor, uri?: Uri, args?: OpenWorkingFileCommandArgs) { diff --git a/src/commands/patches.ts b/src/commands/patches.ts index 38589c1c74732..a1b4b5bbba61e 100644 --- a/src/commands/patches.ts +++ b/src/commands/patches.ts @@ -3,7 +3,8 @@ import type { TextEditor } from 'vscode'; import { env, Uri, window, workspace } from 'vscode'; import type { ScmResource } from '../@types/vscode.git.resources'; import { ScmResourceGroupType } from '../@types/vscode.git.resources.enums'; -import { Commands } from '../constants.commands'; +import type { GlCommands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { IntegrationId } from '../constants.integrations'; import type { Container } from '../container'; import { CancellationError } from '../errors'; @@ -25,7 +26,7 @@ import { command } from '../system/vscode/command'; import type { CommandContext } from './base'; import { ActiveEditorCommand, - Command, + GlCommandBase, isCommandContextViewNodeHasCommit, isCommandContextViewNodeHasComparison, isCommandContextViewNodeHasFileCommit, @@ -42,10 +43,10 @@ export interface CreatePatchCommandArgs { description?: string; } -abstract class CreatePatchCommandBase extends Command { +abstract class CreatePatchCommandBase extends GlCommandBase { constructor( protected readonly container: Container, - command: Commands | Commands[], + command: GlCommands | GlCommands[], ) { super(command); } @@ -161,7 +162,7 @@ abstract class CreatePatchCommandBase extends Command { @command() export class CreatePatchCommand extends CreatePatchCommandBase { constructor(container: Container) { - super(container, Commands.CreatePatch); + super(container, GlCommand.CreatePatch); } async execute(args?: CreatePatchCommandArgs) { @@ -185,7 +186,7 @@ export class CreatePatchCommand extends CreatePatchCommandBase { @command() export class CopyPatchToClipboardCommand extends CreatePatchCommandBase { constructor(container: Container) { - super(container, Commands.CopyPatchToClipboard); + super(container, GlCommand.CopyPatchToClipboard); } async execute(args?: CreatePatchCommandArgs) { @@ -200,9 +201,9 @@ export class CopyPatchToClipboardCommand extends CreatePatchCommandBase { } @command() -export class ApplyPatchFromClipboardCommand extends Command { +export class ApplyPatchFromClipboardCommand extends GlCommandBase { constructor(private readonly container: Container) { - super([Commands.ApplyPatchFromClipboard, Commands.PastePatchFromClipboard]); + super([GlCommand.ApplyPatchFromClipboard, GlCommand.PastePatchFromClipboard]); } async execute() { @@ -249,7 +250,7 @@ export class ApplyPatchFromClipboardCommand extends Command { @command() export class CreateCloudPatchCommand extends CreatePatchCommandBase { constructor(container: Container) { - super(container, [Commands.CreateCloudPatch, Commands.ShareAsCloudPatch]); + super(container, [GlCommand.CreateCloudPatch, GlCommand.ShareAsCloudPatch]); } async execute(args?: CreatePatchCommandArgs) { @@ -273,7 +274,7 @@ export class CreateCloudPatchCommand extends CreatePatchCommandBase { @command() export class OpenPatchCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.OpenPatch); + super(GlCommand.OpenPatch); } async execute(editor?: TextEditor) { @@ -318,9 +319,9 @@ export interface OpenCloudPatchCommandArgs { } @command() -export class OpenCloudPatchCommand extends Command { +export class OpenCloudPatchCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.OpenCloudPatch); + super(GlCommand.OpenCloudPatch); } async execute(args?: OpenCloudPatchCommandArgs) { diff --git a/src/commands/quickCommand.steps.ts b/src/commands/quickCommand.steps.ts index af4d26d67a78d..b703a7b554bef 100644 --- a/src/commands/quickCommand.steps.ts +++ b/src/commands/quickCommand.steps.ts @@ -1,7 +1,7 @@ import type { QuickInputButton, QuickPick, QuickPickItem } from 'vscode'; import { ThemeIcon } from 'vscode'; import { GlyphChars, quickPickTitleMaxChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import { Container } from '../container'; import type { FeatureAccess, RepoFeatureAccess } from '../features'; import { PlusFeatures } from '../features'; @@ -993,7 +993,7 @@ export function* pickBranchOrTagStepMultiRepo< label: 'Choose a Pull Request...', iconPath: new ThemeIcon('git-pull-request'), alwaysShow: true, - item: createCrossCommandReference>(Commands.ShowLaunchpad, { + item: createCrossCommandReference>(GlCommand.ShowLaunchpad, { source: 'quick-wizard', }), }; @@ -2622,7 +2622,9 @@ function getShowRepositoryStatusStepItems< } if (context.status.files.length) { - items.push(new CommandQuickPickItem('Close Unchanged Files', new ThemeIcon('x'), Commands.CloseUnchangedFiles)); + items.push( + new CommandQuickPickItem('Close Unchanged Files', new ThemeIcon('x'), GlCommand.CloseUnchangedFiles), + ); } return items; @@ -2687,7 +2689,7 @@ export async function* ensureAccessStep< detail: 'Click to learn more about Launchpad', iconPath: new ThemeIcon('rocket'), onDidSelect: () => - void executeCommand(Commands.OpenWalkthrough, { + void executeCommand(GlCommand.OpenWalkthrough, { step: 'accelerate-pr-reviews', source: 'launchpad', detail: 'info', diff --git a/src/commands/quickCommand.ts b/src/commands/quickCommand.ts index 58bf2291577c3..71bced2c40df2 100644 --- a/src/commands/quickCommand.ts +++ b/src/commands/quickCommand.ts @@ -1,6 +1,6 @@ import type { InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscode'; import type { Keys } from '../constants'; -import type { Commands } from '../constants.commands'; +import type { GlCommands } from '../constants.commands'; import type { Container } from '../container'; import { createQuickPickSeparator } from '../quickpicks/items/common'; import type { DirectiveQuickPickItem } from '../quickpicks/items/directive'; @@ -396,7 +396,7 @@ export function endSteps(state: PartialStepState) { } export interface CrossCommandReference { - command: Commands; + command: GlCommands; args?: T; } @@ -404,6 +404,6 @@ export function isCrossCommandReference(value: any): value is Cross return value.command != null; } -export function createCrossCommandReference(command: Commands, args: T): CrossCommandReference { +export function createCrossCommandReference(command: GlCommands, args: T): CrossCommandReference { return { command: command, args: args }; } diff --git a/src/commands/quickWizard.base.ts b/src/commands/quickWizard.base.ts index c0fbbe2ced9a4..7192eaf101843 100644 --- a/src/commands/quickWizard.base.ts +++ b/src/commands/quickWizard.base.ts @@ -1,6 +1,6 @@ import type { Disposable, InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscode'; import { InputBoxValidationSeverity, QuickInputButtons, window } from 'vscode'; -import type { Commands } from '../constants.commands'; +import type { GlCommands } from '../constants.commands'; import { Container } from '../container'; import { Directive, isDirective, isDirectiveQuickPickItem } from '../quickpicks/items/directive'; import { log } from '../system/decorators/log'; @@ -8,7 +8,7 @@ import type { Deferred } from '../system/promise'; import { isPromise } from '../system/promise'; import { configuration } from '../system/vscode/configuration'; import type { KeyMapping } from '../system/vscode/keyboard'; -import { Command } from './base'; +import { GlCommandBase } from './base'; import type { GitWizardCommandArgs } from './gitWizard'; import type { CustomStep, QuickCommand, QuickInputStep, QuickPickStep, StepSelection } from './quickCommand'; import { isCustomStep, isQuickCommand, isQuickInputStep, isQuickPickStep, StepResultBreak } from './quickCommand'; @@ -29,12 +29,12 @@ export type AnyQuickWizardCommandArgs = QuickWizardCommandArgs | GitWizardComman export type QuickWizardCommandArgsWithCompletion = T & { completion?: Deferred }; -export abstract class QuickWizardCommandBase extends Command { +export abstract class QuickWizardCommandBase extends GlCommandBase { private startedWith: 'menu' | 'command' = 'menu'; constructor( protected readonly container: Container, - command: Commands | Commands[], + command: GlCommands | GlCommands[], ) { super(command); } diff --git a/src/commands/quickWizard.ts b/src/commands/quickWizard.ts index 2e993fd17ec79..faeb454bb6914 100644 --- a/src/commands/quickWizard.ts +++ b/src/commands/quickWizard.ts @@ -1,4 +1,4 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import type { LaunchpadCommandArgs } from '../plus/launchpad/launchpad'; import type { StartWorkCommandArgs } from '../plus/startWork/startWork'; @@ -12,7 +12,7 @@ export type QuickWizardCommandArgs = LaunchpadCommandArgs | StartWorkCommandArgs @command() export class QuickWizardCommand extends QuickWizardCommandBase { constructor(container: Container) { - super(container, [Commands.ShowLaunchpad, Commands.StartWork]); + super(container, [GlCommand.ShowLaunchpad, GlCommand.StartWork]); } protected override preExecute( @@ -20,10 +20,10 @@ export class QuickWizardCommand extends QuickWizardCommandBase { args?: QuickWizardCommandArgsWithCompletion, ) { switch (context.command) { - case Commands.ShowLaunchpad: + case GlCommand.ShowLaunchpad: return this.execute({ command: 'launchpad', ...args }); - case Commands.StartWork: + case GlCommand.StartWork: return this.execute({ command: 'startWork', ...args }); default: diff --git a/src/commands/rebaseEditor.ts b/src/commands/rebaseEditor.ts index 8a37ec5a8e2dd..b3f7b67780f3d 100644 --- a/src/commands/rebaseEditor.ts +++ b/src/commands/rebaseEditor.ts @@ -1,12 +1,12 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class DisableRebaseEditorCommand extends Command { +export class DisableRebaseEditorCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.DisableRebaseEditor); + super(GlCommand.DisableRebaseEditor); } execute() { @@ -15,9 +15,9 @@ export class DisableRebaseEditorCommand extends Command { } @command() -export class EnableRebaseEditorCommand extends Command { +export class EnableRebaseEditorCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.EnableRebaseEditor); + super(GlCommand.EnableRebaseEditor); } execute() { diff --git a/src/commands/refreshHover.ts b/src/commands/refreshHover.ts index 78fa870393778..3ddd21064b000 100644 --- a/src/commands/refreshHover.ts +++ b/src/commands/refreshHover.ts @@ -1,12 +1,12 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { command, executeCoreCommand } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class RefreshHoverCommand extends Command { +export class RefreshHoverCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.RefreshHover); + super(GlCommand.RefreshHover); } async execute() { diff --git a/src/commands/remoteProviders.ts b/src/commands/remoteProviders.ts index 83defec168089..2bf50a7120ee2 100644 --- a/src/commands/remoteProviders.ts +++ b/src/commands/remoteProviders.ts @@ -1,4 +1,4 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import type { GitCommit } from '../git/models/commit'; import type { GitRemote } from '../git/models/remote'; @@ -10,7 +10,7 @@ import { createMarkdownCommandLink } from '../system/commands'; import { first } from '../system/iterable'; import { command } from '../system/vscode/command'; import type { CommandContext } from './base'; -import { Command, isCommandContextViewNodeHasRemote } from './base'; +import { GlCommandBase, isCommandContextViewNodeHasRemote } from './base'; export interface ConnectRemoteProviderCommandArgs { remote: string; @@ -18,7 +18,7 @@ export interface ConnectRemoteProviderCommandArgs { } @command() -export class ConnectRemoteProviderCommand extends Command { +export class ConnectRemoteProviderCommand extends GlCommandBase { static createMarkdownCommandLink(args: ConnectRemoteProviderCommandArgs): string; static createMarkdownCommandLink(remote: GitRemote): string; static createMarkdownCommandLink(argsOrRemote: ConnectRemoteProviderCommandArgs | GitRemote): string { @@ -32,11 +32,11 @@ export class ConnectRemoteProviderCommand extends Command { args = argsOrRemote; } - return createMarkdownCommandLink(Commands.ConnectRemoteProvider, args); + return createMarkdownCommandLink(GlCommand.ConnectRemoteProvider, args); } constructor(private readonly container: Container) { - super(Commands.ConnectRemoteProvider); + super(GlCommand.ConnectRemoteProvider); } protected override preExecute(context: CommandContext, args?: ConnectRemoteProviderCommandArgs) { @@ -111,7 +111,7 @@ export interface DisconnectRemoteProviderCommandArgs { } @command() -export class DisconnectRemoteProviderCommand extends Command { +export class DisconnectRemoteProviderCommand extends GlCommandBase { static createMarkdownCommandLink(args: DisconnectRemoteProviderCommandArgs): string; static createMarkdownCommandLink(remote: GitRemote): string; static createMarkdownCommandLink(argsOrRemote: DisconnectRemoteProviderCommandArgs | GitRemote): string { @@ -125,11 +125,11 @@ export class DisconnectRemoteProviderCommand extends Command { args = argsOrRemote; } - return createMarkdownCommandLink(Commands.DisconnectRemoteProvider, args); + return createMarkdownCommandLink(GlCommand.DisconnectRemoteProvider, args); } constructor(private readonly container: Container) { - super(Commands.DisconnectRemoteProvider); + super(GlCommand.DisconnectRemoteProvider); } protected override preExecute(context: CommandContext, args?: DisconnectRemoteProviderCommandArgs) { diff --git a/src/commands/repositories.ts b/src/commands/repositories.ts index 28c944caf894c..43d41063284dc 100644 --- a/src/commands/repositories.ts +++ b/src/commands/repositories.ts @@ -1,13 +1,13 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class FetchRepositoriesCommand extends Command { +export class FetchRepositoriesCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.FetchRepositories); + super(GlCommand.FetchRepositories); } async execute() { @@ -19,9 +19,9 @@ export class FetchRepositoriesCommand extends Command { } @command() -export class PullRepositoriesCommand extends Command { +export class PullRepositoriesCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.PullRepositories); + super(GlCommand.PullRepositories); } async execute() { @@ -33,9 +33,9 @@ export class PullRepositoriesCommand extends Command { } @command() -export class PushRepositoriesCommand extends Command { +export class PushRepositoriesCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.PushRepositories); + super(GlCommand.PushRepositories); } async execute() { diff --git a/src/commands/resetViewsLayout.ts b/src/commands/resetViewsLayout.ts index 3c2043f52f29e..e9c58bb3d30d7 100644 --- a/src/commands/resetViewsLayout.ts +++ b/src/commands/resetViewsLayout.ts @@ -1,14 +1,14 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { ViewIds } from '../constants.views'; import { viewIdsByDefaultContainerId } from '../constants.views'; import type { Container } from '../container'; import { command, executeCoreCommand } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class ResetViewsLayoutCommand extends Command { +export class ResetViewsLayoutCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.ResetViewsLayout); + super(GlCommand.ResetViewsLayout); } async execute() { diff --git a/src/commands/resets.ts b/src/commands/resets.ts index 02322b41db826..4969e227b8d47 100644 --- a/src/commands/resets.ts +++ b/src/commands/resets.ts @@ -1,13 +1,13 @@ import type { MessageItem } from 'vscode'; import { ConfigurationTarget, window } from 'vscode'; import { resetAvatarCache } from '../avatars'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import type { QuickPickItemOfT } from '../quickpicks/items/common'; import { createQuickPickSeparator } from '../quickpicks/items/common'; import { command } from '../system/vscode/command'; import { configuration } from '../system/vscode/configuration'; -import { Command } from './base'; +import { GlCommandBase } from './base'; const resetTypes = [ 'ai', @@ -23,9 +23,9 @@ const resetTypes = [ type ResetType = 'all' | (typeof resetTypes)[number]; @command() -export class ResetCommand extends Command { +export class ResetCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.Reset); + super(GlCommand.Reset); } async execute() { type ResetQuickPickItem = QuickPickItemOfT; @@ -213,9 +213,9 @@ export class ResetCommand extends Command { } @command() -export class ResetAIKeyCommand extends Command { +export class ResetAIKeyCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.ResetAIKey); + super(GlCommand.ResetAIKey); } async execute() { diff --git a/src/commands/searchCommits.ts b/src/commands/searchCommits.ts index 97d9dd4553eec..3fa65cab4f2e8 100644 --- a/src/commands/searchCommits.ts +++ b/src/commands/searchCommits.ts @@ -1,4 +1,4 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { SearchQuery } from '../constants.search'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; @@ -6,7 +6,7 @@ import { command } from '../system/vscode/command'; import { configuration } from '../system/vscode/configuration'; import { SearchResultsNode } from '../views/nodes/searchResultsNode'; import type { CommandContext } from './base'; -import { Command, isCommandContextViewNodeHasRepository } from './base'; +import { GlCommandBase, isCommandContextViewNodeHasRepository } from './base'; export interface SearchCommitsCommandArgs { search?: Partial; @@ -19,13 +19,13 @@ export interface SearchCommitsCommandArgs { } @command() -export class SearchCommitsCommand extends Command { +export class SearchCommitsCommand extends GlCommandBase { constructor(private readonly container: Container) { - super([Commands.SearchCommits, Commands.SearchCommitsInView]); + super([GlCommand.SearchCommits, GlCommand.SearchCommitsInView]); } protected override preExecute(context: CommandContext, args?: SearchCommitsCommandArgs) { - if (context.command === Commands.SearchCommitsInView) { + if (context.command === GlCommand.SearchCommitsInView) { args = { ...args }; args.showResultsInSideBar = true; } else if (context.type === 'viewItem') { diff --git a/src/commands/showCommitsInView.ts b/src/commands/showCommitsInView.ts index 2737181a95deb..e70f3a45a4d1a 100644 --- a/src/commands/showCommitsInView.ts +++ b/src/commands/showCommitsInView.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import { GitUri } from '../git/gitUri'; @@ -22,11 +22,11 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand { static createMarkdownCommandLink(args: ShowCommitsInViewCommandArgs): string; static createMarkdownCommandLink(argsOrSha: ShowCommitsInViewCommandArgs | string, repoPath?: string): string { const args = typeof argsOrSha === 'string' ? { refs: [argsOrSha], repoPath: repoPath } : argsOrSha; - return createMarkdownCommandLink(Commands.ShowCommitsInView, args); + return createMarkdownCommandLink(GlCommand.ShowCommitsInView, args); } constructor(private readonly container: Container) { - super(Commands.ShowCommitsInView); + super(GlCommand.ShowCommitsInView); } async execute(editor?: TextEditor, uri?: Uri, args?: ShowCommitsInViewCommandArgs) { diff --git a/src/commands/showLastQuickPick.ts b/src/commands/showLastQuickPick.ts index 35921e3b48088..f1ab89c56e6c6 100644 --- a/src/commands/showLastQuickPick.ts +++ b/src/commands/showLastQuickPick.ts @@ -1,15 +1,15 @@ import { commands } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { showGenericErrorMessage } from '../messages'; import { Logger } from '../system/logger'; import { command } from '../system/vscode/command'; -import { Command, getLastCommand } from './base'; +import { getLastCommand, GlCommandBase } from './base'; @command() -export class ShowLastQuickPickCommand extends Command { +export class ShowLastQuickPickCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.ShowLastQuickPick); + super(GlCommand.ShowLastQuickPick); } execute() { diff --git a/src/commands/showQuickBranchHistory.ts b/src/commands/showQuickBranchHistory.ts index 904b5849fe311..15a87251e2fae 100644 --- a/src/commands/showQuickBranchHistory.ts +++ b/src/commands/showQuickBranchHistory.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import { GitUri } from '../git/gitUri'; @@ -18,11 +18,11 @@ export interface ShowQuickBranchHistoryCommandArgs { @command() export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand { constructor(private readonly container: Container) { - super([Commands.ShowQuickBranchHistory, Commands.ShowQuickCurrentBranchHistory]); + super([GlCommand.ShowQuickBranchHistory, GlCommand.ShowQuickCurrentBranchHistory]); } protected override preExecute(context: CommandContext, args?: ShowQuickBranchHistoryCommandArgs) { - if (context.command === Commands.ShowQuickCurrentBranchHistory) { + if (context.command === GlCommand.ShowQuickCurrentBranchHistory) { args = { ...args }; args.branch = 'HEAD'; } diff --git a/src/commands/showQuickCommit.ts b/src/commands/showQuickCommit.ts index b168b88b6da83..68ec5c6490925 100644 --- a/src/commands/showQuickCommit.ts +++ b/src/commands/showQuickCommit.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import { reveal } from '../git/actions/commit'; @@ -32,15 +32,15 @@ export class ShowQuickCommitCommand extends ActiveEditorCachedCommand { static createMarkdownCommandLink(args: ShowQuickCommitCommandArgs): string; static createMarkdownCommandLink(argsOrSha: ShowQuickCommitCommandArgs | string, repoPath?: string): string { const args = typeof argsOrSha === 'string' ? { sha: argsOrSha, repoPath: repoPath } : argsOrSha; - return createMarkdownCommandLink(Commands.ShowQuickCommit, args); + return createMarkdownCommandLink(GlCommand.ShowQuickCommit, args); } constructor(private readonly container: Container) { - super([Commands.RevealCommitInView, Commands.ShowQuickCommit]); + super([GlCommand.RevealCommitInView, GlCommand.ShowQuickCommit]); } protected override preExecute(context: CommandContext, args?: ShowQuickCommitCommandArgs) { - if (context.command === Commands.RevealCommitInView) { + if (context.command === GlCommand.RevealCommitInView) { args = { ...args }; args.revealInView = true; } diff --git a/src/commands/showQuickCommitFile.ts b/src/commands/showQuickCommitFile.ts index 7294ceae496e5..c4d029e9aabab 100644 --- a/src/commands/showQuickCommitFile.ts +++ b/src/commands/showQuickCommitFile.ts @@ -1,6 +1,6 @@ import type { TextEditor } from 'vscode'; import { Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import { GitUri } from '../git/gitUri'; @@ -31,11 +31,11 @@ export interface ShowQuickCommitFileCommandArgs { @command() export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand { static createMarkdownCommandLink(args: ShowQuickCommitFileCommandArgs): string { - return createMarkdownCommandLink(Commands.ShowQuickCommitFile, args); + return createMarkdownCommandLink(GlCommand.ShowQuickCommitFile, args); } constructor(private readonly container: Container) { - super(Commands.ShowQuickCommitFile); + super(GlCommand.ShowQuickCommitFile); } protected override async preExecute(context: CommandContext, args?: ShowQuickCommitFileCommandArgs) { @@ -153,9 +153,9 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand { export class ShowQuickCommitRevisionCommand extends ActiveEditorCachedCommand { constructor(private readonly container: Container) { super([ - Commands.ShowQuickCommitRevision, - Commands.ShowQuickCommitRevisionInDiffLeft, - Commands.ShowQuickCommitRevisionInDiffRight, + GlCommand.ShowQuickCommitRevision, + GlCommand.ShowQuickCommitRevisionInDiffLeft, + GlCommand.ShowQuickCommitRevisionInDiffRight, ]); } diff --git a/src/commands/showQuickFileHistory.ts b/src/commands/showQuickFileHistory.ts index 4621f8fe213df..d9a4b4b39087f 100644 --- a/src/commands/showQuickFileHistory.ts +++ b/src/commands/showQuickFileHistory.ts @@ -1,5 +1,5 @@ import type { Range, TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import { GitUri } from '../git/gitUri'; @@ -27,19 +27,19 @@ export interface ShowQuickFileHistoryCommandArgs { export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand { constructor(private readonly container: Container) { super([ - Commands.OpenFileHistory, - Commands.OpenFolderHistory, - Commands.ShowQuickFileHistory, - Commands.QuickOpenFileHistory, - Commands.Deprecated_ShowFileHistoryInView, + GlCommand.OpenFileHistory, + GlCommand.OpenFolderHistory, + GlCommand.ShowQuickFileHistory, + GlCommand.QuickOpenFileHistory, + GlCommand.Deprecated_ShowFileHistoryInView, ]); } protected override preExecute(context: CommandContext, args?: ShowQuickFileHistoryCommandArgs) { if ( - context.command === Commands.OpenFileHistory || - context.command === Commands.OpenFolderHistory || - context.command === Commands.Deprecated_ShowFileHistoryInView + context.command === GlCommand.OpenFileHistory || + context.command === GlCommand.OpenFolderHistory || + context.command === GlCommand.Deprecated_ShowFileHistoryInView ) { args = { ...args }; args.showInSideBar = true; diff --git a/src/commands/showQuickRepoStatus.ts b/src/commands/showQuickRepoStatus.ts index e66cbefc2f016..24fc5f3b024b5 100644 --- a/src/commands/showQuickRepoStatus.ts +++ b/src/commands/showQuickRepoStatus.ts @@ -1,17 +1,17 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; export interface ShowQuickRepoStatusCommandArgs { repoPath?: string; } @command() -export class ShowQuickRepoStatusCommand extends Command { +export class ShowQuickRepoStatusCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.ShowQuickRepoStatus); + super(GlCommand.ShowQuickRepoStatus); } async execute(args?: ShowQuickRepoStatusCommandArgs) { diff --git a/src/commands/showQuickStashList.ts b/src/commands/showQuickStashList.ts index a028b2ccc6b47..004d35616615d 100644 --- a/src/commands/showQuickStashList.ts +++ b/src/commands/showQuickStashList.ts @@ -1,17 +1,17 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; export interface ShowQuickStashListCommandArgs { repoPath?: string; } @command() -export class ShowQuickStashListCommand extends Command { +export class ShowQuickStashListCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.ShowQuickStashList); + super(GlCommand.ShowQuickStashList); } execute(args?: ShowQuickStashListCommandArgs) { diff --git a/src/commands/showView.ts b/src/commands/showView.ts index d478c648d3746..36d21c6840a46 100644 --- a/src/commands/showView.ts +++ b/src/commands/showView.ts @@ -1,35 +1,35 @@ import { window } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import type { GraphWebviewShowingArgs } from '../plus/webviews/graph/registration'; import { command, executeCoreCommand } from '../system/vscode/command'; import type { HomeWebviewShowingArgs } from '../webviews/home/registration'; import type { CommandContext } from './base'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class ShowViewCommand extends Command { +export class ShowViewCommand extends GlCommandBase { constructor(private readonly container: Container) { super([ - Commands.ShowAccountView, - Commands.ShowBranchesView, - Commands.ShowCommitDetailsView, - Commands.ShowCommitsView, - Commands.ShowContributorsView, - Commands.ShowDraftsView, - Commands.ShowFileHistoryView, - Commands.ShowGraphView, - Commands.ShowHomeView, - Commands.ShowLaunchpadView, - Commands.ShowLineHistoryView, - Commands.ShowRemotesView, - Commands.ShowRepositoriesView, - Commands.ShowSearchAndCompareView, - Commands.ShowStashesView, - Commands.ShowTagsView, - Commands.ShowTimelineView, - Commands.ShowWorktreesView, - Commands.ShowWorkspacesView, + GlCommand.ShowAccountView, + GlCommand.ShowBranchesView, + GlCommand.ShowCommitDetailsView, + GlCommand.ShowCommitsView, + GlCommand.ShowContributorsView, + GlCommand.ShowDraftsView, + GlCommand.ShowFileHistoryView, + GlCommand.ShowGraphView, + GlCommand.ShowHomeView, + GlCommand.ShowLaunchpadView, + GlCommand.ShowLineHistoryView, + GlCommand.ShowRemotesView, + GlCommand.ShowRepositoriesView, + GlCommand.ShowSearchAndCompareView, + GlCommand.ShowStashesView, + GlCommand.ShowTagsView, + GlCommand.ShowTimelineView, + GlCommand.ShowWorktreesView, + GlCommand.ShowWorkspacesView, ]); } @@ -54,50 +54,50 @@ export class ShowViewCommand extends Command { } async execute(context: CommandContext, ...args: unknown[]) { - const command = context.command as Commands; + const command = context.command; switch (command) { - case Commands.ShowAccountView: + case GlCommand.ShowAccountView: return this.container.views.home.show( undefined, ...([{ focusAccount: true }, ...args] as HomeWebviewShowingArgs), ); - case Commands.ShowBranchesView: + case GlCommand.ShowBranchesView: return this.container.views.showView('branches'); - case Commands.ShowCommitDetailsView: + case GlCommand.ShowCommitDetailsView: void this.notifyWhenNoRepository('Inspect'); return this.container.views.commitDetails.show(); - case Commands.ShowCommitsView: + case GlCommand.ShowCommitsView: return this.container.views.showView('commits'); - case Commands.ShowContributorsView: + case GlCommand.ShowContributorsView: return this.container.views.showView('contributors'); - case Commands.ShowDraftsView: + case GlCommand.ShowDraftsView: return this.container.views.showView('drafts'); - case Commands.ShowFileHistoryView: + case GlCommand.ShowFileHistoryView: return this.container.views.showView('fileHistory'); - case Commands.ShowGraphView: + case GlCommand.ShowGraphView: void this.notifyWhenNoRepository('the Commit Graph'); return this.container.views.graph.show(undefined, ...(args as GraphWebviewShowingArgs)); - case Commands.ShowHomeView: + case GlCommand.ShowHomeView: return this.container.views.home.show(undefined, ...(args as HomeWebviewShowingArgs)); - case Commands.ShowLaunchpadView: + case GlCommand.ShowLaunchpadView: return this.container.views.showView('launchpad'); - case Commands.ShowLineHistoryView: + case GlCommand.ShowLineHistoryView: return this.container.views.showView('lineHistory'); - case Commands.ShowRemotesView: + case GlCommand.ShowRemotesView: return this.container.views.showView('remotes'); - case Commands.ShowRepositoriesView: + case GlCommand.ShowRepositoriesView: return this.container.views.showView('repositories'); - case Commands.ShowSearchAndCompareView: + case GlCommand.ShowSearchAndCompareView: return this.container.views.showView('searchAndCompare'); - case Commands.ShowStashesView: + case GlCommand.ShowStashesView: return this.container.views.showView('stashes'); - case Commands.ShowTagsView: + case GlCommand.ShowTagsView: return this.container.views.showView('tags'); - case Commands.ShowTimelineView: + case GlCommand.ShowTimelineView: return this.container.views.timeline.show(); - case Commands.ShowWorktreesView: + case GlCommand.ShowWorktreesView: return this.container.views.showView('worktrees'); - case Commands.ShowWorkspacesView: + case GlCommand.ShowWorkspacesView: return this.container.views.showView('workspaces'); } diff --git a/src/commands/stashApply.ts b/src/commands/stashApply.ts index b890c6b185014..22b1b63ba56c7 100644 --- a/src/commands/stashApply.ts +++ b/src/commands/stashApply.ts @@ -1,4 +1,4 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { apply, pop } from '../git/actions/stash'; import type { GitStashCommit } from '../git/models/commit'; @@ -6,7 +6,7 @@ import type { GitStashReference } from '../git/models/reference'; import type { CommandQuickPickItem } from '../quickpicks/items/common'; import { command } from '../system/vscode/command'; import type { CommandContext } from './base'; -import { Command, isCommandContextViewNodeHasCommit, isCommandContextViewNodeHasRepository } from './base'; +import { GlCommandBase, isCommandContextViewNodeHasCommit, isCommandContextViewNodeHasRepository } from './base'; export interface StashApplyCommandArgs { deleteAfter?: boolean; @@ -17,9 +17,9 @@ export interface StashApplyCommandArgs { } @command() -export class StashApplyCommand extends Command { +export class StashApplyCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.StashApply); + super(GlCommand.StashApply); } protected override async preExecute(context: CommandContext, args?: StashApplyCommandArgs) { diff --git a/src/commands/stashSave.ts b/src/commands/stashSave.ts index 34dba97321a4a..6814ab728535a 100644 --- a/src/commands/stashSave.ts +++ b/src/commands/stashSave.ts @@ -1,7 +1,7 @@ import type { Uri } from 'vscode'; import type { ScmResource } from '../@types/vscode.git.resources'; import { ScmResourceGroupType, ScmStatus } from '../@types/vscode.git.resources.enums'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { Features } from '../features'; import { push } from '../git/actions/stash'; @@ -9,7 +9,7 @@ import { GitUri } from '../git/gitUri'; import { command } from '../system/vscode/command'; import type { CommandContext } from './base'; import { - Command, + GlCommandBase, isCommandContextViewNodeHasFile, isCommandContextViewNodeHasRepoPath, isCommandContextViewNodeHasRepository, @@ -26,9 +26,9 @@ export interface StashSaveCommandArgs { } @command() -export class StashSaveCommand extends Command { +export class StashSaveCommand extends GlCommandBase { constructor(private readonly container: Container) { - super([Commands.StashSave, Commands.StashSaveFiles]); + super([GlCommand.StashSave, GlCommand.StashSaveFiles]); } protected override async preExecute(context: CommandContext, args?: StashSaveCommandArgs) { diff --git a/src/commands/switchAIModel.ts b/src/commands/switchAIModel.ts index 9a38ec5ba541d..7b68a7e3f4c0b 100644 --- a/src/commands/switchAIModel.ts +++ b/src/commands/switchAIModel.ts @@ -1,12 +1,12 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class SwitchAIModelCommand extends Command { +export class SwitchAIModelCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.SwitchAIModel); + super(GlCommand.SwitchAIModel); } async execute() { diff --git a/src/commands/switchMode.ts b/src/commands/switchMode.ts index 1ddbdc762c6f5..00384a638b41c 100644 --- a/src/commands/switchMode.ts +++ b/src/commands/switchMode.ts @@ -1,17 +1,17 @@ import { ConfigurationTarget } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { showModePicker } from '../quickpicks/modePicker'; import { log } from '../system/decorators/log'; import { getLogScope, setLogScopeExit } from '../system/logger.scope'; import { command } from '../system/vscode/command'; import { configuration } from '../system/vscode/configuration'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class SwitchModeCommand extends Command { +export class SwitchModeCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.SwitchMode); + super(GlCommand.SwitchMode); } @log({ args: false, scoped: true, singleLine: true, timed: false }) @@ -43,9 +43,9 @@ export class SwitchModeCommand extends Command { } @command() -export class ToggleReviewModeCommand extends Command { +export class ToggleReviewModeCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.ToggleReviewMode); + super(GlCommand.ToggleReviewMode); } @log({ args: false, singleLine: true, timed: false }) @@ -59,9 +59,9 @@ export class ToggleReviewModeCommand extends Command { } @command() -export class ToggleZenModeCommand extends Command { +export class ToggleZenModeCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.ToggleZenMode); + super(GlCommand.ToggleZenMode); } @log({ args: false, singleLine: true, timed: false }) diff --git a/src/commands/toggleCodeLens.ts b/src/commands/toggleCodeLens.ts index c9d89a83fe46b..e8823a50b3113 100644 --- a/src/commands/toggleCodeLens.ts +++ b/src/commands/toggleCodeLens.ts @@ -1,12 +1,12 @@ -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { command } from '../system/vscode/command'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class ToggleCodeLensCommand extends Command { +export class ToggleCodeLensCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.ToggleCodeLens); + super(GlCommand.ToggleCodeLens); } execute() { diff --git a/src/commands/toggleFileAnnotations.ts b/src/commands/toggleFileAnnotations.ts index 92327fba4bc56..42e3353dafcbc 100644 --- a/src/commands/toggleFileAnnotations.ts +++ b/src/commands/toggleFileAnnotations.ts @@ -1,7 +1,7 @@ import type { TextEditor, TextEditorEdit, Uri } from 'vscode'; import type { AnnotationContext } from '../annotations/annotationProvider'; import type { ChangesAnnotationContext } from '../annotations/gutterChangesAnnotationProvider'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { showGenericErrorMessage } from '../messages'; import { Logger } from '../system/logger'; @@ -12,7 +12,7 @@ import { ActiveEditorCommand, EditorCommand } from './base'; @command() export class ClearFileAnnotationsCommand extends EditorCommand { constructor(private readonly container: Container) { - super([Commands.ClearFileAnnotations, Commands.ComputingFileAnnotations]); + super([GlCommand.ClearFileAnnotations, GlCommand.ComputingFileAnnotations]); } async execute(editor: TextEditor | undefined, _edit: TextEditorEdit, uri?: Uri): Promise { @@ -54,7 +54,7 @@ export type ToggleFileAnnotationCommandArgs = @command() export class ToggleFileBlameCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super([Commands.ToggleFileBlame, Commands.ToggleFileBlameInDiffLeft, Commands.ToggleFileBlameInDiffRight]); + super([GlCommand.ToggleFileBlame, GlCommand.ToggleFileBlameInDiffLeft, GlCommand.ToggleFileBlameInDiffRight]); } execute(editor: TextEditor, uri?: Uri, args?: ToggleFileBlameAnnotationCommandArgs): Promise { @@ -68,7 +68,7 @@ export class ToggleFileBlameCommand extends ActiveEditorCommand { @command() export class ToggleFileChangesCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.ToggleFileChanges); + super(GlCommand.ToggleFileChanges); } execute(editor: TextEditor, uri?: Uri, args?: ToggleFileChangesAnnotationCommandArgs): Promise { @@ -83,9 +83,9 @@ export class ToggleFileChangesCommand extends ActiveEditorCommand { export class ToggleFileHeatmapCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { super([ - Commands.ToggleFileHeatmap, - Commands.ToggleFileHeatmapInDiffLeft, - Commands.ToggleFileHeatmapInDiffRight, + GlCommand.ToggleFileHeatmap, + GlCommand.ToggleFileHeatmapInDiffLeft, + GlCommand.ToggleFileHeatmapInDiffRight, ]); } diff --git a/src/commands/toggleLineBlame.ts b/src/commands/toggleLineBlame.ts index 84c7b2b16ca62..b5d37af26482f 100644 --- a/src/commands/toggleLineBlame.ts +++ b/src/commands/toggleLineBlame.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { showGenericErrorMessage } from '../messages'; import { Logger } from '../system/logger'; @@ -9,7 +9,7 @@ import { ActiveEditorCommand } from './base'; @command() export class ToggleLineBlameCommand extends ActiveEditorCommand { constructor(private readonly container: Container) { - super(Commands.ToggleLineBlame); + super(GlCommand.ToggleLineBlame); } async execute(editor: TextEditor, _uri?: Uri): Promise { diff --git a/src/commands/walkthroughs.ts b/src/commands/walkthroughs.ts index a3611b5d8de72..014046daec8ea 100644 --- a/src/commands/walkthroughs.ts +++ b/src/commands/walkthroughs.ts @@ -1,16 +1,16 @@ import type { WalkthroughSteps } from '../constants'; import { urls } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Source, Sources } from '../constants.telemetry'; import type { Container } from '../container'; import { command, executeCommand } from '../system/vscode/command'; import { openUrl, openWalkthrough as openWalkthroughCore } from '../system/vscode/utils'; -import { Command } from './base'; +import { GlCommandBase } from './base'; @command() -export class GetStartedCommand extends Command { +export class GetStartedCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.GetStarted); + super(GlCommand.GetStarted); } execute(extensionIdOrsource?: Sources) { @@ -25,9 +25,9 @@ export interface OpenWalkthroughCommandArgs extends Source { } @command() -export class OpenWalkthroughCommand extends Command { +export class OpenWalkthroughCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.OpenWalkthrough); + super(GlCommand.OpenWalkthrough); } execute(args?: OpenWalkthroughCommandArgs) { @@ -49,13 +49,13 @@ function openWalkthrough(container: Container, args?: OpenWalkthroughCommandArgs // gitlens.openWalkthrough @command() -export class WalkthroughOpenWalkthroughCommand extends Command { +export class WalkthroughOpenWalkthroughCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughOpenWalkthrough); + super(GlCommand.WalkthroughOpenWalkthrough); } execute() { - const command = Commands.OpenWalkthrough; + const command = GlCommand.OpenWalkthrough; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'open/walkthrough', @@ -67,13 +67,13 @@ export class WalkthroughOpenWalkthroughCommand extends Command { // gitlens.plus.upgrade @command() -export class WalkthroughPlusUpgradeCommand extends Command { +export class WalkthroughPlusUpgradeCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughPlusUpgrade); + super(GlCommand.WalkthroughPlusUpgrade); } execute() { - const command = Commands.PlusUpgrade; + const command = GlCommand.PlusUpgrade; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'plus/upgrade', @@ -85,9 +85,9 @@ export class WalkthroughPlusUpgradeCommand extends Command { // https://help.gitkraken.com/gitlens/gitlens-home/ @command() -export class WalkthroughOpenHelpCenterCommand extends Command { +export class WalkthroughOpenHelpCenterCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughOpenHelpCenter); + super(GlCommand.WalkthroughOpenHelpCenter); } execute() { @@ -103,13 +103,13 @@ export class WalkthroughOpenHelpCenterCommand extends Command { // gitlens.plus.signUp @command() -export class WalkthroughPlusSignUpCommand extends Command { +export class WalkthroughPlusSignUpCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughPlusSignUp); + super(GlCommand.WalkthroughPlusSignUp); } execute() { - const command = Commands.PlusSignUp; + const command = GlCommand.PlusSignUp; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'plus/sign-up', @@ -120,13 +120,13 @@ export class WalkthroughPlusSignUpCommand extends Command { } @command() -export class WalkthroughPlusReactivateCommand extends Command { +export class WalkthroughPlusReactivateCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughPlusReactivate); + super(GlCommand.WalkthroughPlusReactivate); } execute() { - const command = Commands.PlusReactivateProTrial; + const command = GlCommand.PlusReactivateProTrial; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'plus/reactivate', @@ -138,9 +138,9 @@ export class WalkthroughPlusReactivateCommand extends Command { // https://help.gitkraken.com/gitlens/gitlens-community-vs-gitlens-pro/ @command() -export class WalkthroughOpenCommunityVsProCommand extends Command { +export class WalkthroughOpenCommunityVsProCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughOpenCommunityVsPro); + super(GlCommand.WalkthroughOpenCommunityVsPro); } execute() { @@ -156,13 +156,13 @@ export class WalkthroughOpenCommunityVsProCommand extends Command { // gitlens.showGraph @command() -export class WalkthroughShowGraphCommand extends Command { +export class WalkthroughShowGraphCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughShowGraph); + super(GlCommand.WalkthroughShowGraph); } execute() { - const command = Commands.ShowGraph; + const command = GlCommand.ShowGraph; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'open/graph', @@ -174,13 +174,13 @@ export class WalkthroughShowGraphCommand extends Command { // workbench.view.extension.gitlensInspect @command() -export class WalkthroughGitLensInspectCommand extends Command { +export class WalkthroughGitLensInspectCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughGitLensInspect); + super(GlCommand.WalkthroughGitLensInspect); } execute() { - const command = Commands.ShowCommitDetailsView; + const command = GlCommand.ShowCommitDetailsView; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'open/inspect', @@ -192,9 +192,9 @@ export class WalkthroughGitLensInspectCommand extends Command { // https://help.gitkraken.com/gitlens/gitlens-home/#interactive-code-history @command() -export class WalkthroughOpenInteractiveCodeHistoryCommand extends Command { +export class WalkthroughOpenInteractiveCodeHistoryCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughOpenInteractiveCodeHistory); + super(GlCommand.WalkthroughOpenInteractiveCodeHistory); } execute() { @@ -210,13 +210,13 @@ export class WalkthroughOpenInteractiveCodeHistoryCommand extends Command { // gitlens.showLaunchpad @command() -export class WalkthroughShowLaunchpadCommand extends Command { +export class WalkthroughShowLaunchpadCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughShowLaunchpad); + super(GlCommand.WalkthroughShowLaunchpad); } execute() { - const command = Commands.ShowLaunchpad; + const command = GlCommand.ShowLaunchpad; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'open/launchpad', @@ -228,13 +228,13 @@ export class WalkthroughShowLaunchpadCommand extends Command { // gitlens.gitCommands.worktree.create @command() -export class WalkthroughWorktreeCreateCommand extends Command { +export class WalkthroughWorktreeCreateCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughWorktreeCreate); + super(GlCommand.WalkthroughWorktreeCreate); } execute() { - const command = Commands.GitCommandsWorktreeCreate; + const command = GlCommand.GitCommandsWorktreeCreate; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'create/worktree', @@ -245,9 +245,9 @@ export class WalkthroughWorktreeCreateCommand extends Command { } @command() -export class WalkthroughOpenDevExPlatformCommand extends Command { +export class WalkthroughOpenDevExPlatformCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthoughOpenDevExPlatform); + super(GlCommand.WalkthoughOpenDevExPlatform); } execute() { @@ -263,9 +263,9 @@ export class WalkthroughOpenDevExPlatformCommand extends Command { // https://help.gitkraken.com/gitlens/gitlens-home/#accelerate-pr-reviews @command() -export class WalkthroughOpenAccelereatePrReviewsCommand extends Command { +export class WalkthroughOpenAccelereatePrReviewsCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughOpenAcceleratePrReviews); + super(GlCommand.WalkthroughOpenAcceleratePrReviews); } execute() { @@ -281,13 +281,13 @@ export class WalkthroughOpenAccelereatePrReviewsCommand extends Command { // gitlens.views.drafts.focus @command() -export class WalkthroughShowDraftsViewCommand extends Command { +export class WalkthroughShowDraftsViewCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughShowDraftsView); + super(GlCommand.WalkthroughShowDraftsView); } execute() { - const command = Commands.ShowDraftsView; + const command = GlCommand.ShowDraftsView; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'open/drafts', @@ -299,9 +299,9 @@ export class WalkthroughShowDraftsViewCommand extends Command { // https://help.gitkraken.com/gitlens/gitlens-home/#streamline-collaboration @command() -export class WalkthroughOpenStreamlineCollaboration extends Command { +export class WalkthroughOpenStreamlineCollaboration extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughOpenStreamlineCollaboration); + super(GlCommand.WalkthroughOpenStreamlineCollaboration); } execute() { @@ -317,13 +317,13 @@ export class WalkthroughOpenStreamlineCollaboration extends Command { // gitlens.plus.cloudIntegrations.connect @command() -export class WalkthroughConnectIntegrationsCommand extends Command { +export class WalkthroughConnectIntegrationsCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughConnectIntegrations); + super(GlCommand.WalkthroughConnectIntegrations); } execute() { - const command = Commands.PlusConnectCloudIntegrations; + const command = GlCommand.PlusConnectCloudIntegrations; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'connect/integrations', @@ -335,13 +335,13 @@ export class WalkthroughConnectIntegrationsCommand extends Command { // gitlens.showSettingsPage!autolinks @command() -export class WalkthroughShowAutolinksCommand extends Command { +export class WalkthroughShowAutolinksCommand extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughShowAutolinks); + super(GlCommand.WalkthroughShowAutolinks); } execute() { - const command = Commands.ShowSettingsPageAndJumpToAutolinks; + const command = GlCommand.ShowSettingsPageAndJumpToAutolinks; this.container.telemetry.sendEvent('walkthrough/action', { type: 'command', name: 'open/autolinks', @@ -353,9 +353,9 @@ export class WalkthroughShowAutolinksCommand extends Command { // https://help.gitkraken.com/gitlens/gitlens-start-here/#integrations @command() -export class WalkthroughOpenStartIntegrations extends Command { +export class WalkthroughOpenStartIntegrations extends GlCommandBase { constructor(private readonly container: Container) { - super(Commands.WalkthroughOpenStartIntegrations); + super(GlCommand.WalkthroughOpenStartIntegrations); } execute() { diff --git a/src/constants.commands.ts b/src/constants.commands.ts index 622d1a87a8a18..f0f5a53f145f7 100644 --- a/src/constants.commands.ts +++ b/src/constants.commands.ts @@ -1,8 +1,9 @@ +import type { Keys } from './constants'; import type { CoreViewContainerIds, TreeViewIds, TreeViewTypes, ViewContainerIds, ViewIds } from './constants.views'; -export const enum Commands { - ActionPrefix = 'gitlens.action.', +export const actionCommandPrefix = 'gitlens.action.'; +export const enum GlCommand { AddAuthors = 'gitlens.addAuthors', BrowseRepoAtRevision = 'gitlens.browseRepoAtRevision', BrowseRepoAtRevisionInNewWindow = 'gitlens.browseRepoAtRevisionInNewWindow', @@ -248,7 +249,6 @@ export const enum Commands { ViewsCopy = 'gitlens.views.copy', ViewsCopyAsMarkdown = 'gitlens.views.copyAsMarkdown', ViewsCopyUrl = 'gitlens.views.copyUrl', - ViewsOpenAllChangedFileDiffs = 'gitlens.views.openChangedFileDiffs', ViewsOpenDirectoryDiff = 'gitlens.views.openDirectoryDiff', ViewsOpenDirectoryDiffWithWorking = 'gitlens.views.openDirectoryDiffWithWorking', ViewsOpenUrl = 'gitlens.views.openUrl', @@ -282,6 +282,17 @@ export const enum Commands { Deprecated_ShowFileHistoryInView = 'gitlens.showFileHistoryInView', } +export type GlCommands = + | `${GlCommand}` + | `gitlens.action.${string}` + | 'gitlens.annotations.nextChange' + | 'gitlens.annotations.previousChange' + | `gitlens.key.${Keys}` + | 'gitlens.plus.refreshRepositoryAccess' + | 'gitlens.launchpad.indicator.action'; + +export type Commands = GlCommands | TreeViewCommands | WebviewCommands | WebviewViewCommands; + export type CoreCommands = | 'cursorMove' | 'editor.action.showHover' @@ -329,144 +340,327 @@ export type CoreGitCommands = | 'git.pushForce' | 'git.undoCommit'; -export type CustomViewCommands = - | 'gitlens.home.openInGraph' - | 'gitlens.home.fetch' - | 'gitlens.home.openPullRequestChanges' - | 'gitlens.home.openPullRequestOnRemote' - | 'gitlens.home.createPullRequest' - | 'gitlens.home.openWorktree' - | 'gitlens.home.switchToBranch' - | 'gitlens.home.createBranch' - | 'gitlens.home.startWork'; +type BranchesViewCommands = `branches.${ + | 'copy' + | 'refresh' + | 'regroup' + | `setLayoutTo${'List' | 'Tree'}` + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setShowAvatars${'On' | 'Off'}` + | `setShowBranchComparison${'On' | 'Off'}` + | `setShowBranchPullRequest${'On' | 'Off'}` + | `setShowRemoteBranches${'On' | 'Off'}` + | `setShowStashes${'On' | 'Off'}`}`; + +type CommitsViewCommands = `commits.${ + | 'copy' + | 'refresh' + | 'regroup' + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setCommitsFilter${'Authors' | 'Off'}` + | `setShowAvatars${'On' | 'Off'}` + | `setShowBranchComparison${'On' | 'Off'}` + | `setShowBranchPullRequest${'On' | 'Off'}` + | `setShowMergeCommits${'On' | 'Off'}` + | `setShowStashes${'On' | 'Off'}`}`; + +type ContributorsViewCommands = `contributors.${ + | 'copy' + | 'refresh' + | 'regroup' + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setShowAllBranches${'On' | 'Off'}` + | `setShowAvatars${'On' | 'Off'}` + | `setShowMergeCommits${'On' | 'Off'}` + | `setShowStatistics${'On' | 'Off'}`}`; + +type DraftsViewCommands = `drafts.${ + | 'copy' + | 'refresh' + | 'info' + | 'create' + | 'delete' + | `setShowAvatars${'On' | 'Off'}`}`; + +type FileHistoryViewCommands = `fileHistory.${ + | 'copy' + | 'refresh' + | 'changeBase' + | `setCursorFollowing${'On' | 'Off'}` + | `setEditorFollowing${'On' | 'Off'}` + | `setRenameFollowing${'On' | 'Off'}` + | `setShowAllBranches${'On' | 'Off'}` + | `setShowMergeCommits${'On' | 'Off'}` + | `setShowAvatars${'On' | 'Off'}`}`; + +type LaunchpadViewCommands = `launchpad.${ + | 'copy' + | 'info' + | 'refresh' + | 'regroup' + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setShowAvatars${'On' | 'Off'}`}`; + +type LineHistoryViewCommands = `lineHistory.${ + | 'copy' + | 'refresh' + | 'changeBase' + | `setEditorFollowing${'On' | 'Off'}` + | `setShowAvatars${'On' | 'Off'}`}`; + +type PullRequestViewCommands = `pullRequest.${ + | 'close' + | 'copy' + | 'refresh' + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setShowAvatars${'On' | 'Off'}`}`; + +type RemotesViewCommands = `remotes.${ + | 'copy' + | 'refresh' + | 'regroup' + | `setLayoutTo${'List' | 'Tree'}` + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setShowAvatars${'On' | 'Off'}` + | `setShowBranchPullRequest${'On' | 'Off'}`}`; + +type RepositoriesViewCommands = `repositories.${ + | 'copy' + | 'refresh' + | 'regroup' + | `setBranchesLayoutTo${'List' | 'Tree'}` + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setAutoRefreshTo${'On' | 'Off'}` + | `setShowAvatars${'On' | 'Off'}` + | `setShowBranchComparison${'On' | 'Off'}` + | `setBranchesShowBranchComparison${'On' | 'Off'}` + | `setShowBranches${'On' | 'Off'}` + | `setShowCommits${'On' | 'Off'}` + | `setShowContributors${'On' | 'Off'}` + | `setShowRemotes${'On' | 'Off'}` + | `setShowStashes${'On' | 'Off'}` + | `setShowTags${'On' | 'Off'}` + | `setShowWorktrees${'On' | 'Off'}` + | `setShowUpstreamStatus${'On' | 'Off'}` + | `setShowSectionOff`}`; + +type ScmGroupedViewCommands = `scm.grouped.${ + | 'welcome.restore' + | 'welcome.dismiss' + | 'focus' + | 'refresh' + | 'detachAll' + | 'regroupAll' + | `${ + | 'branches' + | 'commits' + | 'contributors' + | 'launchpad' + | 'remotes' + | 'repositories' + | 'searchAndCompare' + | 'stashes' + | 'tags' + | 'worktrees'}${'' | '.regroup' | '.detach' | '.setAsDefault'}` + | 'toggleSection' + | 'toggleSectionByNode'}`; + +type SearchAndCompareViewCommands = `searchAndCompare.${ + | 'copy' + | 'refresh' + | 'regroup' + | 'clear' + | 'pin' + | 'unpin' + | 'swapComparison' + | 'selectForCompare' + | 'compareWithSelected' + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setKeepResultsTo${'On' | 'Off'}` + | `setShowAvatars${'On' | 'Off'}` + | `setFilesFilterOn${'Left' | 'Right'}` + | 'setFilesFilterOff'}`; + +type StashesViewCommands = `stashes.${'copy' | 'refresh' | 'regroup' | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`}`; +type TagsViewCommands = `tags.${ + | 'copy' + | 'refresh' + | 'regroup' + | `setLayoutTo${'List' | 'Tree'}` + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setShowAvatars${'On' | 'Off'}`}`; + +type WorkspacesViewCommands = `workspaces.${ + | 'info' + | 'copy' + | 'refresh' + | 'addRepos' + | 'addReposFromLinked' + | 'changeAutoAddSetting' + | 'convert' + | 'create' + | 'createLocal' + | 'delete' + | 'locateAllRepos' + | 'openLocal' + | 'openLocalNewWindow' + | `repo.${'locate' | 'open' | 'openInNewWindow' | 'addToWindow' | 'remove'}`}`; + +type WorktreesViewCommands = `worktrees.${ + | 'copy' + | 'refresh' + | 'regroup' + | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` + | `setShowAvatars${'On' | 'Off'}` + | `setShowBranchComparison${'On' | 'Off'}` + | `setShowBranchPullRequest${'On' | 'Off'}` + | `setShowStashes${'On' | 'Off'}`}`; export type TreeViewCommands = `gitlens.views.${ - | `branches.${ - | 'copy' - | 'refresh' - | `setLayoutTo${'List' | 'Tree'}` - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setShowAvatars${'On' | 'Off'}` - | `setShowBranchComparison${'On' | 'Off'}` - | `setShowBranchPullRequest${'On' | 'Off'}` - | `setShowRemoteBranches${'On' | 'Off'}` - | `setShowStashes${'On' | 'Off'}`}` - | `commits.${ - | 'copy' - | 'refresh' - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setCommitsFilter${'Authors' | 'Off'}` - | `setShowAvatars${'On' | 'Off'}` - | `setShowBranchComparison${'On' | 'Off'}` - | `setShowBranchPullRequest${'On' | 'Off'}` - | `setShowMergeCommits${'On' | 'Off'}` - | `setShowStashes${'On' | 'Off'}`}` - | `contributors.${ - | 'copy' - | 'refresh' - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setShowAllBranches${'On' | 'Off'}` - | `setShowAvatars${'On' | 'Off'}` - | `setShowMergeCommits${'On' | 'Off'}` - | `setShowStatistics${'On' | 'Off'}`}` - | `drafts.${'copy' | 'refresh' | 'info' | 'create' | 'delete' | `setShowAvatars${'On' | 'Off'}`}` - | `fileHistory.${ - | 'copy' - | 'refresh' - | 'changeBase' - | `setCursorFollowing${'On' | 'Off'}` - | `setEditorFollowing${'On' | 'Off'}` - | `setRenameFollowing${'On' | 'Off'}` - | `setShowAllBranches${'On' | 'Off'}` - | `setShowMergeCommits${'On' | 'Off'}` - | `setShowAvatars${'On' | 'Off'}`}` - | `launchpad.${ - | 'copy' - | 'info' - | 'refresh' - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setShowAvatars${'On' | 'Off'}`}` - | `lineHistory.${ - | 'copy' - | 'refresh' - | 'changeBase' - | `setEditorFollowing${'On' | 'Off'}` - | `setShowAvatars${'On' | 'Off'}`}` - | `pullRequest.${ - | 'close' - | 'copy' - | 'refresh' - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setShowAvatars${'On' | 'Off'}`}` - | `remotes.${ - | 'copy' - | 'refresh' - | `setLayoutTo${'List' | 'Tree'}` - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setShowAvatars${'On' | 'Off'}` - | `setShowBranchPullRequest${'On' | 'Off'}`}` - | `repositories.${ - | 'copy' - | 'refresh' - | `setBranchesLayoutTo${'List' | 'Tree'}` - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setAutoRefreshTo${'On' | 'Off'}` - | `setShowAvatars${'On' | 'Off'}` - | `setShowBranchComparison${'On' | 'Off'}` - | `setBranchesShowBranchComparison${'On' | 'Off'}` - | `setShowBranches${'On' | 'Off'}` - | `setShowCommits${'On' | 'Off'}` - | `setShowContributors${'On' | 'Off'}` - | `setShowRemotes${'On' | 'Off'}` - | `setShowStashes${'On' | 'Off'}` - | `setShowTags${'On' | 'Off'}` - | `setShowWorktrees${'On' | 'Off'}` - | `setShowUpstreamStatus${'On' | 'Off'}` - | `setShowSectionOff`}` - | `searchAndCompare.${ - | 'copy' - | 'refresh' - | 'clear' - | 'pin' - | 'unpin' - | 'swapComparison' - | 'selectForCompare' - | 'compareWithSelected' - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setKeepResultsTo${'On' | 'Off'}` - | `setShowAvatars${'On' | 'Off'}` - | `setFilesFilterOn${'Left' | 'Right'}` - | 'setFilesFilterOff'}` - | `stashes.${'copy' | 'refresh' | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`}` - | `tags.${ - | 'copy' - | 'refresh' - | `setLayoutTo${'List' | 'Tree'}` - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setShowAvatars${'On' | 'Off'}`}` - | `workspaces.${ - | 'info' - | 'copy' - | 'refresh' - | 'addRepos' - | 'addReposFromLinked' - | 'changeAutoAddSetting' - | 'convert' - | 'create' - | 'createLocal' - | 'delete' - | 'locateAllRepos' - | 'openLocal' - | 'openLocalNewWindow' - | `repo.${'locate' | 'open' | 'openInNewWindow' | 'addToWindow' | 'remove'}`}` - | `worktrees.${ - | 'copy' - | 'refresh' - | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}` - | `setShowAvatars${'On' | 'Off'}` - | `setShowBranchComparison${'On' | 'Off'}` - | `setShowBranchPullRequest${'On' | 'Off'}` - | `setShowStashes${'On' | 'Off'}`}`}`; + | BranchesViewCommands + | CommitsViewCommands + | ContributorsViewCommands + | DraftsViewCommands + | FileHistoryViewCommands + | LaunchpadViewCommands + | LineHistoryViewCommands + | PullRequestViewCommands + | RemotesViewCommands + | RepositoriesViewCommands + | ScmGroupedViewCommands + | SearchAndCompareViewCommands + | StashesViewCommands + | TagsViewCommands + | WorkspacesViewCommands + | WorktreesViewCommands + | 'clearComparison' + | 'clearReviewed' + | 'copy' + | 'copyAsMarkdown' + | 'copyUrl' + | 'copyUrl.multi' + | 'openUrl' + | 'openUrl.multi' + | 'collapseNode' + | 'dismissNode' + | 'editNode' + | 'expandNode' + | 'loadMoreChildren' + | 'loadAllChildren' + | 'refreshNode' + | 'setShowRelativeDateMarkersOn' + | 'setShowRelativeDateMarkersOff' + | 'fetch' + | 'publishBranch' + | 'publishRepository' + | 'pull' + | 'push' + | 'pushWithForce' + | 'closeRepository' + | 'setAsDefault' + | 'unsetAsDefault' + | 'openInTerminal' + | 'openInIntegratedTerminal' + | 'star' + | 'star.multi' + | 'unstar' + | 'unstar.multi' + | 'browseRepoAtRevision' + | 'browseRepoAtRevisionInNewWindow' + | 'browseRepoBeforeRevision' + | 'browseRepoBeforeRevisionInNewWindow' + | 'addAuthors' + | 'addAuthor' + | 'addAuthor.multi' + | 'openBranchOnRemote' + | 'openBranchOnRemote.multi' + | 'copyRemoteCommitUrl' + | 'copyRemoteCommitUrl.multi' + | 'openCommitOnRemote' + | 'openCommitOnRemote.multi' + | 'openChanges' + | 'openChangesWithWorking' + | 'openPreviousChangesWithWorking' + | 'openFile' + | 'openFileRevision' + | 'openChangedFiles' + | 'openOnlyChangedFiles' + | 'openChangedFileDiffs' + | 'openChangedFileDiffsWithWorking' + | 'openChangedFileDiffsIndividually' + | 'openChangedFileDiffsWithWorkingIndividually' + | 'openChangedFileRevisions' + | 'applyChanges' + | 'highlightChanges' + | 'highlightRevisionChanges' + | 'restore' + | 'switchToAnotherBranch' + | 'switchToBranch' + | 'switchToCommit' + | 'switchToTag' + | 'addRemote' + | 'pruneRemote' + | 'removeRemote' + | 'stageDirectory' + | 'stageFile' + | 'unstageDirectory' + | 'unstageFile' + | 'openChangedFileDiffsWithMergeBase' + | 'compareAncestryWithWorking' + | 'compareWithHead' + | 'compareBranchWithHead' + | 'compareWithMergeBase' + | 'compareWithUpstream' + | 'compareWithSelected' + | 'selectForCompare' + | 'compareFileWithSelected' + | 'selectFileForCompare' + | 'compareWithWorking' + | 'setBranchComparisonToWorking' + | 'setBranchComparisonToBranch' + | 'cherryPick' + | 'cherryPick.multi' + | 'title.createBranch' + | 'createBranch' + | 'deleteBranch' + | 'deleteBranch.multi' + | 'renameBranch' + | 'stash.apply' + | 'stash.delete' + | 'stash.delete.multi' + | 'stash.rename' + | 'title.createTag' + | 'createTag' + | 'deleteTag' + | 'deleteTag.multi' + | 'mergeBranchInto' + | 'pushToCommit' + | 'rebaseOntoBranch' + | 'rebaseOntoUpstream' + | 'rebaseOntoCommit' + | 'resetCommit' + | 'resetToCommit' + | 'resetToTip' + | 'revert' + | 'undoCommit' + | 'createPullRequest' + | 'openPullRequest' + | 'openPullRequestChanges' + | 'openPullRequestComparison' + | 'draft.open' + | 'draft.openOnWeb' + | 'title.createWorktree' + | 'createWorktree' + | 'deleteWorktree' + | 'deleteWorktree.multi' + | 'openWorktree' + | 'openInWorktree' + | 'revealRepositoryInExplorer' + | 'revealWorktreeInExplorer' + | 'openWorktreeInNewWindow' + | 'openWorktreeInNewWindow.multi' + | 'setResultsCommitsFilterAuthors' + | 'setResultsCommitsFilterOff'}`; type ExtractSuffix = U extends `${Prefix}${infer V}` ? V : never; type FilterCommands = U extends `${Prefix}${infer V}` ? `${Prefix}${V}` : never; @@ -480,3 +674,161 @@ export type TreeViewCommandSuffixesByViewType = Extract `gitlens.views.${T}.`, FilterCommands<`gitlens.views.${T}.`, TreeViewCommands> >; + +type HomeWebviewCommands = `home.${ + | 'openPullRequestChanges' + | 'openPullRequestComparison' + | 'openPullRequestOnRemote' + | 'createPullRequest' + | 'openWorktree' + | 'switchToBranch' + | 'fetch' + | 'openInGraph' + | 'createBranch' + | 'startWork'}`; + +type GraphWebviewCommands = `graph.${ + | 'switchToEditorLayout' + | 'switchToPanelLayout' + | 'split' + | 'push' + | 'pull' + | 'fetch' + | 'pushWithForce' + | 'publishBranch' + | 'switchToAnotherBranch' + | 'createBranch' + | 'deleteBranch' + | 'copyRemoteBranchUrl' + | 'openBranchOnRemote' + | 'mergeBranchInto' + | 'rebaseOntoBranch' + | 'rebaseOntoUpstream' + | 'renameBranch' + | 'switchToBranch' + | 'hideLocalBranch' + | 'hideRemoteBranch' + | 'hideRemote' + | 'hideRefGroup' + | 'hideTag' + | 'cherryPick' + | 'copyRemoteCommitUrl' + | 'copyRemoteCommitUrl.multi' + | 'openCommitOnRemote' + | 'openCommitOnRemote.multi' + | 'commitViaSCM' + | 'rebaseOntoCommit' + | 'resetCommit' + | 'resetToCommit' + | 'resetToTip' + | 'revert' + | 'showInDetailsView' + | 'switchToCommit' + | 'undoCommit' + | 'stash.save' + | 'stash.apply' + | 'stash.delete' + | 'stash.rename' + | 'createTag' + | 'deleteTag' + | 'switchToTag' + | 'resetToTag' + | 'createWorktree' + | 'createPullRequest' + | 'openPullRequest' + | 'openPullRequestChanges' + | 'openPullRequestComparison' + | 'openPullRequestOnRemote' + | 'openChangedFileDiffsWithMergeBase' + | 'compareWithUpstream' + | 'compareWithHead' + | 'compareBranchWithHead' + | 'compareWithWorking' + | 'compareWithMergeBase' + | 'compareAncestryWithWorking' + | 'copy' + | 'copyMessage' + | 'copySha' + | 'addAuthor' + | 'columnAuthorOn' + | 'columnAuthorOff' + | 'columnDateTimeOn' + | 'columnDateTimeOff' + | 'columnShaOn' + | 'columnShaOff' + | 'columnChangesOn' + | 'columnChangesOff' + | 'columnGraphOn' + | 'columnGraphOff' + | 'columnMessageOn' + | 'columnMessageOff' + | 'columnRefOn' + | 'columnRefOff' + | 'columnGraphCompact' + | 'columnGraphDefault' + | 'scrollMarkerLocalBranchOn' + | 'scrollMarkerLocalBranchOff' + | 'scrollMarkerRemoteBranchOn' + | 'scrollMarkerRemoteBranchOff' + | 'scrollMarkerStashOn' + | 'scrollMarkerStashOff' + | 'scrollMarkerTagOn' + | 'scrollMarkerTagOff' + | 'scrollMarkerPullRequestOn' + | 'scrollMarkerPullRequestOff' + | 'copyDeepLinkToBranch' + | 'copyDeepLinkToCommit' + | 'copyDeepLinkToRepo' + | 'copyDeepLinkToTag' + | 'shareAsCloudPatch' + | 'createPatch' + | 'createCloudPatch' + | 'openChangedFiles' + | 'openOnlyChangedFiles' + | 'openChangedFileDiffs' + | 'openChangedFileDiffsWithWorking' + | 'openChangedFileDiffsIndividually' + | 'openChangedFileDiffsWithWorkingIndividually' + | 'openChangedFileRevisions' + | 'resetColumnsDefault' + | 'resetColumnsCompact' + | 'openInWorktree' + | 'openWorktree' + | 'openWorktreeInNewWindow' + | 'copyWorkingChangesToWorktree' + | 'generateCommitMessage'}`; + +type TimelineWebviewCommands = `timeline.${'refresh' | 'split'}`; + +export type WebviewCommands = `gitlens.${HomeWebviewCommands | GraphWebviewCommands | TimelineWebviewCommands}`; + +type CommitDetailsWebviewViewCommands = `commitDetails.${'refresh'}`; + +type HomeWebviewViewCommands = `home.${ + | 'refresh' + | 'pull' + | 'push' + | 'publishBranch' + | 'disablePreview' + | 'previewFeedback' + | 'whatsNew' + | 'help' + | 'issues' + | 'discussions' + | 'account.resync'}`; + +type GraphDetailsWebviewViewCommands = `graphDetails.${'refresh'}`; + +type GraphWebviewViewCommands = `graph.${'refresh' | 'openInTab'}`; + +type PatchDetailsWebviewViewCommands = `patchDetails.${'refresh' | 'close'}`; + +type TimelineWebviewViewCommands = `timeline.${'refresh' | 'openInTab'}`; + +export type WebviewViewCommands = `gitlens.views.${ + | CommitDetailsWebviewViewCommands + | HomeWebviewViewCommands + | GraphDetailsWebviewViewCommands + | GraphWebviewViewCommands + | PatchDetailsWebviewViewCommands + | TimelineWebviewViewCommands}`; diff --git a/src/constants.telemetry.ts b/src/constants.telemetry.ts index 8ca3fc9ee7a5e..64170b0e39308 100644 --- a/src/constants.telemetry.ts +++ b/src/constants.telemetry.ts @@ -1,7 +1,7 @@ import type { Config, GraphBranchesVisibility, GraphConfig } from './config'; import type { WalkthroughSteps } from './constants'; import type { AIModels, AIProviders } from './constants.ai'; -import type { Commands } from './constants.commands'; +import type { GlCommand } from './constants.commands'; import type { IntegrationId, SupportedCloudIntegrationIds } from './constants.integrations'; import type { SubscriptionState, SubscriptionStateString } from './constants.subscription'; import type { CustomEditorTypes, TreeViewTypes, WebviewTypes, WebviewViewTypes } from './constants.views'; @@ -404,7 +404,7 @@ interface CommandEventData { } interface GitCommandEventData { - command: Commands.GitCommands; + command: GlCommand.GitCommands; 'context.mode'?: string; 'context.submode'?: string; webview?: string; @@ -903,10 +903,9 @@ export type TrackedUsage = { lastUsedAt: number; }; -export type CommandExecutionTrackedFeatures = `command:${Commands}:executed`; export type TrackedUsageFeatures = | `${WebviewTypes}Webview` | `${TreeViewTypes | WebviewViewTypes}View` | `${CustomEditorTypes}Editor`; export type WalkthroughUsageKeys = 'home:walkthrough:dismissed'; -export type TrackedUsageKeys = `${TrackedUsageFeatures}:shown` | CommandExecutionTrackedFeatures | WalkthroughUsageKeys; +export type TrackedUsageKeys = `${TrackedUsageFeatures}:shown` | `command:${string}:executed` | WalkthroughUsageKeys; diff --git a/src/container.ts b/src/container.ts index 2949b9d320c39..0e1078fa4ebce 100644 --- a/src/container.ts +++ b/src/container.ts @@ -13,7 +13,8 @@ import type { ToggleFileAnnotationCommandArgs } from './commands/toggleFileAnnot import type { DateStyle, FileAnnotationType, Mode } from './config'; import { fromOutputLevel } from './config'; import { extensionPrefix } from './constants'; -import { Commands } from './constants.commands'; +import type { GlCommands } from './constants.commands'; +import { GlCommand } from './constants.commands'; import { EventBus } from './eventBus'; import { GitFileSystemProvider } from './git/fsProvider'; import { GitProviderService } from './git/gitProviderService'; @@ -668,16 +669,16 @@ export class Container { } if (mode.annotations != null) { - let command: Commands | undefined; + let command: GlCommands | undefined; switch (mode.annotations) { case 'blame': - command = Commands.ToggleFileBlame; + command = GlCommand.ToggleFileBlame; break; case 'changes': - command = Commands.ToggleFileChanges; + command = GlCommand.ToggleFileChanges; break; case 'heatmap': - command = Commands.ToggleFileHeatmap; + command = GlCommand.ToggleFileHeatmap; break; } diff --git a/src/extension.ts b/src/extension.ts index a8e0b6b92bf9e..66e38fa69ab18 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -8,7 +8,7 @@ import type { CreatePullRequestOnRemoteCommandArgs } from './commands/createPull import type { OpenPullRequestOnRemoteCommandArgs } from './commands/openPullRequestOnRemote'; import { fromOutputLevel } from './config'; import { trackableSchemes } from './constants'; -import { Commands } from './constants.commands'; +import { GlCommand } from './constants.commands'; import { SyncedStorageKeys } from './constants.storage'; import { Container } from './container'; import { isGitUri } from './git/gitUri'; @@ -202,7 +202,7 @@ export async function activate(context: ExtensionContext): Promise { if (ctx.type !== 'createPullRequest') return; - void (await executeCommand(Commands.CreatePullRequestOnRemote, { + void (await executeCommand(GlCommand.CreatePullRequestOnRemote, { base: undefined, compare: ctx.branch.isRemote ? getBranchNameWithoutRemote(ctx.branch.name) @@ -309,7 +309,7 @@ function registerBuiltInActionRunners(container: Container): void { run: async ctx => { if (ctx.type !== 'openPullRequest') return; - void (await executeCommand(Commands.OpenPullRequestOnRemote, { + void (await executeCommand(GlCommand.OpenPullRequestOnRemote, { pr: { url: ctx.pullRequest.url }, })); }, diff --git a/src/git/actions.ts b/src/git/actions.ts index d49afe94ac114..658ff832d5b05 100644 --- a/src/git/actions.ts +++ b/src/git/actions.ts @@ -2,13 +2,13 @@ import type { Uri } from 'vscode'; import type { BrowseRepoAtRevisionCommandArgs } from '../commands/browseRepoAtRevision'; import type { GitWizardCommandArgs } from '../commands/gitWizard'; import type { QuickWizardCommandArgsWithCompletion } from '../commands/quickWizard.base'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import { defer } from '../system/promise'; import { executeCommand, executeEditorCommand } from '../system/vscode/command'; export async function executeGitCommand(args: GitWizardCommandArgs): Promise { const deferred = defer(); - void (await executeCommand>(Commands.GitCommands, { + void (await executeCommand>(GlCommand.GitCommands, { ...args, completion: deferred, })); @@ -16,7 +16,7 @@ export async function executeGitCommand(args: GitWizardCommandArgs): Promise(Commands.BrowseRepoAtRevision, undefined, { + void (await executeEditorCommand(GlCommand.BrowseRepoAtRevision, undefined, { uri: uri, before: options?.before, openInNewWindow: options?.openInNewWindow, diff --git a/src/git/actions/commit.ts b/src/git/actions/commit.ts index 936355efb2940..efd3a3118d848 100644 --- a/src/git/actions/commit.ts +++ b/src/git/actions/commit.ts @@ -10,7 +10,7 @@ import type { ShowQuickCommitCommandArgs } from '../../commands/showQuickCommit' import type { ShowQuickCommitFileCommandArgs } from '../../commands/showQuickCommitFile'; import type { FileAnnotationType } from '../../config'; import { GlyphChars } from '../../constants'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import { Container } from '../../container'; import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/protocol'; import { showRevisionFilesPicker } from '../../quickpicks/revisionFilesPicker'; @@ -371,7 +371,7 @@ export async function openChanges( if (file.status === 'A' && hasCommit) { const commit = await commitOrRefs.getCommitForFile(file); - void executeCommand(Commands.DiffWithPrevious, { + void executeCommand(GlCommand.DiffWithPrevious, { commit: commit, showOptions: options, }); @@ -392,7 +392,7 @@ export async function openChanges( const lhsUri = file.status === 'R' || file.status === 'C' ? GitUri.fromFile(file, refs.repoPath, refs.lhs, true) : rhsUri; - void (await executeCommand(Commands.DiffWith, { + void (await executeCommand(GlCommand.DiffWith, { repoPath: refs.repoPath, lhs: { uri: lhsUri, sha: refs.lhs, title: options?.lhsTitle }, rhs: { uri: rhsUri, sha: refs.rhs, title: options?.rhsTitle }, @@ -462,7 +462,7 @@ export async function openChangesWithWorking( options = { preserveFocus: true, preview: false, ...options }; - void (await executeEditorCommand(Commands.DiffWithWorking, undefined, { + void (await executeEditorCommand(GlCommand.DiffWithWorking, undefined, { uri: GitUri.fromFile(file, ref.repoPath, ref.ref), showOptions: options, lhsTitle: options?.lhsTitle, @@ -567,7 +567,7 @@ export async function openFile( options = { preserveFocus: true, preview: false, ...options }; - void (await executeEditorCommand(Commands.OpenWorkingFile, undefined, { + void (await executeEditorCommand(GlCommand.OpenWorkingFile, undefined, { uri: uri, showOptions: options, })); @@ -678,7 +678,7 @@ export async function openFileOnRemote(fileOrUri: string | GitFile | Uri, ref?: if (typeof fileOrUri !== 'string' && fileOrUri.status === '?') return; } - void (await executeCommand<[Uri, OpenFileOnRemoteCommandArgs]>(Commands.OpenFileOnRemote, uri, { + void (await executeCommand<[Uri, OpenFileOnRemoteCommandArgs]>(GlCommand.OpenFileOnRemote, uri, { sha: ref?.ref, })); } @@ -785,7 +785,7 @@ export async function showDetailsQuickPick(commit: GitCommit, uri?: Uri): Promis export async function showDetailsQuickPick(commit: GitCommit, file?: string | GitFile): Promise; export async function showDetailsQuickPick(commit: GitCommit, fileOrUri?: string | GitFile | Uri): Promise { if (fileOrUri == null) { - void (await executeCommand(Commands.ShowQuickCommit, { commit: commit })); + void (await executeCommand(GlCommand.ShowQuickCommit, { commit: commit })); return; } @@ -796,7 +796,7 @@ export async function showDetailsQuickPick(commit: GitCommit, fileOrUri?: string uri = GitUri.fromFile(fileOrUri, commit.repoPath, commit.ref); } - void (await executeCommand<[Uri, ShowQuickCommitFileCommandArgs]>(Commands.ShowQuickCommitFile, uri, { + void (await executeCommand<[Uri, ShowQuickCommitFileCommandArgs]>(GlCommand.ShowQuickCommitFile, uri, { sha: commit.sha, commit: commit, })); @@ -822,7 +822,7 @@ export async function showInCommitGraph( commit: GitRevisionReference | GitCommit, options?: { preserveFocus?: boolean }, ): Promise { - void (await executeCommand(Commands.ShowInCommitGraph, { + void (await executeCommand(GlCommand.ShowInCommitGraph, { ref: getReferenceFromRevision(commit), preserveFocus: options?.preserveFocus, })); @@ -852,7 +852,7 @@ export async function openOnlyChangedFiles(commitOrFiles: GitCommit | GitFile[]) return; } - void (await executeCommand(Commands.OpenOnlyChangedFiles, { + void (await executeCommand(GlCommand.OpenOnlyChangedFiles, { uris: files.filter(f => f.status !== 'D').map(f => f.uri), })); } diff --git a/src/git/formatters/commitFormatter.ts b/src/git/formatters/commitFormatter.ts index e9b7e3eec03eb..8a3a1e0f37b2b 100644 --- a/src/git/formatters/commitFormatter.ts +++ b/src/git/formatters/commitFormatter.ts @@ -16,7 +16,7 @@ import type { ShowQuickCommitCommandArgs } from '../../commands/showQuickCommit' import { ShowQuickCommitFileCommand } from '../../commands/showQuickCommitFile'; import type { DateStyle } from '../../config'; import { GlyphChars } from '../../constants'; -import { Commands } from '../../constants.commands'; +import { actionCommandPrefix, GlCommand } from '../../constants.commands'; import { Container } from '../../container'; import { emojify } from '../../emojis'; import { arePlusFeaturesEnabled } from '../../plus/gk/utils'; @@ -477,7 +477,7 @@ export class CommitFormatter extends Formatter { } commands += `  [$(search)](${createMarkdownCommandLink( - Commands.RevealCommitInView, + GlCommand.RevealCommitInView, { repoPath: this._item.repoPath, sha: this._item.sha, @@ -487,7 +487,7 @@ export class CommitFormatter extends Formatter { if (arePlusFeaturesEnabled()) { commands += `  [$(gitlens-graph)](${createMarkdownCommandLink( - Commands.ShowInCommitGraph, + GlCommand.ShowInCommitGraph, // Avoid including the message here, it just bloats the command url { ref: getReferenceFromRevision(this._item, { excludeMessage: true }) }, )} "Open in Commit Graph")`; @@ -517,7 +517,7 @@ export class CommitFormatter extends Formatter { pr.state }, ${pr.formatDateFromNow()}")`; } else if (isPromise(pr)) { - commands += `${separator}[$(git-pull-request) PR $(loading~spin)](command:${Commands.RefreshHover} "Searching for a Pull Request (if any) that introduced this commit...")`; + commands += `${separator}[$(git-pull-request) PR $(loading~spin)](command:${GlCommand.RefreshHover} "Searching for a Pull Request (if any) that introduced this commit...")`; } } else if (remotes != null) { const [remote] = remotes; @@ -813,7 +813,7 @@ export class CommitFormatter extends Formatter { } else if (isPromise(pr)) { text = this._options.outputFormat === 'markdown' - ? `[PR $(loading~spin)](command:${Commands.RefreshHover} "Searching for a Pull Request (if any) that introduced this commit...")` + ? `[PR $(loading~spin)](command:${GlCommand.RefreshHover} "Searching for a Pull Request (if any) that introduced this commit...")` : this._options?.pullRequestPendingMessage ?? ''; } else { return this._padOrTruncate('', this._options.tokenOptions.pullRequest); @@ -941,7 +941,7 @@ export class CommitFormatter extends Formatter { } function createMarkdownActionCommandLink(action: Action, args: Omit): string { - return createMarkdownCommandLink(`${Commands.ActionPrefix}${action}` as Commands, { + return createMarkdownCommandLink(`${actionCommandPrefix}${action}`, { ...args, type: action, }); diff --git a/src/messages.ts b/src/messages.ts index d0370344c4995..5027cd29eac8b 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -2,7 +2,7 @@ import type { MessageItem } from 'vscode'; import { ConfigurationTarget, window } from 'vscode'; import type { SuppressedMessages } from './config'; import { urls } from './constants'; -import { Commands } from './constants.commands'; +import { GlCommand } from './constants.commands'; import type { BlameIgnoreRevsFileError } from './git/errors'; import { BlameIgnoreRevsFileBadRevisionError } from './git/errors'; import type { GitCommit } from './git/models/commit'; @@ -91,7 +91,7 @@ export async function showGenericErrorMessage(message: string): Promise { ); if (result != null) { - void executeCommand(Commands.EnableDebugLogging); + void executeCommand(GlCommand.EnableDebugLogging); } } } @@ -237,7 +237,7 @@ export async function showWhatsNewMessage(majorVersion: string) { 'info', `Upgraded to GitLens ${majorVersion}${ majorVersion === '16' - ? ` with an all new [Home view](${createMarkdownCommandLink(Commands.ShowHomeView, { + ? ` with an all new [Home view](${createMarkdownCommandLink(GlCommand.ShowHomeView, { source: 'whatsnew', })} "Show Home view") reimagined as a hub for your current, future, and recent work, [consolidated Source Control views](command:gitlens.views.scm.grouped.focus "Show GitLens view"), and much more.` : " — see what's new." diff --git a/src/partners.ts b/src/partners.ts index 69d2699d9a059..52d84746c93c1 100644 --- a/src/partners.ts +++ b/src/partners.ts @@ -2,7 +2,7 @@ import type { CancellationTokenSource, Extension, ExtensionContext, Uri } from ' import { extensions } from 'vscode'; import type { ActionContext, HoverCommandsActionContext } from './api/gitlens'; import type { InviteToLiveShareCommandArgs } from './commands/inviteToLiveShare'; -import { Commands } from './constants.commands'; +import { GlCommand } from './constants.commands'; import { Container } from './container'; import { executeCommand, executeCoreCommand } from './system/vscode/command'; import type { ContactPresence } from './vsls/vsls'; @@ -76,12 +76,12 @@ function registerLiveShare(context: ExtensionContext) { }, run: async (context: ActionContext) => { if (context.type !== 'hover.commands' || context.commit.author.name === 'You') { - await executeCommand(Commands.InviteToLiveShare, {}); + await executeCommand(GlCommand.InviteToLiveShare, {}); return; } - await executeCommand(Commands.InviteToLiveShare, { + await executeCommand(GlCommand.InviteToLiveShare, { email: context.commit.author.email, }); }, diff --git a/src/plus/gk/account/__debug__accountDebug.ts b/src/plus/gk/account/__debug__accountDebug.ts index 2e448bcf0085e..837700af8bd40 100644 --- a/src/plus/gk/account/__debug__accountDebug.ts +++ b/src/plus/gk/account/__debug__accountDebug.ts @@ -1,6 +1,6 @@ import type { Disposable } from 'vscode'; import { ThemeIcon, window } from 'vscode'; -import { Commands } from '../../../constants.commands'; +import { GlCommand } from '../../../constants.commands'; import { proFeaturePreviewUsages, proTrialLengthInDays, @@ -77,7 +77,7 @@ class AccountDebug { private readonly service: SubscriptionServiceFacade, ) { this.container.context.subscriptions.push( - registerCommand(Commands.PlusSimulateSubscription, () => this.showSimulator()), + registerCommand(GlCommand.PlusSimulateSubscription, () => this.showSimulator()), ); } diff --git a/src/plus/gk/account/subscriptionService.ts b/src/plus/gk/account/subscriptionService.ts index 5f7697de70910..b55dbd0a32bd9 100644 --- a/src/plus/gk/account/subscriptionService.ts +++ b/src/plus/gk/account/subscriptionService.ts @@ -23,7 +23,7 @@ import { import type { OpenWalkthroughCommandArgs } from '../../../commands/walkthroughs'; import { urls } from '../../../constants'; import type { CoreColors } from '../../../constants.colors'; -import { Commands } from '../../../constants.commands'; +import { GlCommand } from '../../../constants.commands'; import type { StoredFeaturePreviewUsagePeriod } from '../../../constants.storage'; import { proFeaturePreviewUsageDurationInDays, @@ -338,24 +338,24 @@ export class SubscriptionService implements Disposable { private registerCommands(): Disposable[] { return [ - registerCommand(Commands.PlusLogin, (src?: Source) => this.loginOrSignUp(false, src)), - registerCommand(Commands.PlusSignUp, (src?: Source) => this.loginOrSignUp(true, src)), - registerCommand(Commands.PlusLogout, (src?: Source) => this.logout(src)), - registerCommand(Commands.GKSwitchOrganization, () => this.switchOrganization()), + registerCommand(GlCommand.PlusLogin, (src?: Source) => this.loginOrSignUp(false, src)), + registerCommand(GlCommand.PlusSignUp, (src?: Source) => this.loginOrSignUp(true, src)), + registerCommand(GlCommand.PlusLogout, (src?: Source) => this.logout(src)), + registerCommand(GlCommand.GKSwitchOrganization, () => this.switchOrganization()), - registerCommand(Commands.PlusManage, (src?: Source) => this.manage(src)), - registerCommand(Commands.PlusShowPlans, (src?: Source) => this.showPlans(src)), - registerCommand(Commands.PlusStartPreviewTrial, (src?: Source) => this.startPreviewTrial(src)), - registerCommand(Commands.PlusReactivateProTrial, (src?: Source) => this.reactivateProTrial(src)), - registerCommand(Commands.PlusResendVerification, (src?: Source) => this.resendVerification(src)), - registerCommand(Commands.PlusUpgrade, (src?: Source) => this.upgrade(src)), + registerCommand(GlCommand.PlusManage, (src?: Source) => this.manage(src)), + registerCommand(GlCommand.PlusShowPlans, (src?: Source) => this.showPlans(src)), + registerCommand(GlCommand.PlusStartPreviewTrial, (src?: Source) => this.startPreviewTrial(src)), + registerCommand(GlCommand.PlusReactivateProTrial, (src?: Source) => this.reactivateProTrial(src)), + registerCommand(GlCommand.PlusResendVerification, (src?: Source) => this.resendVerification(src)), + registerCommand(GlCommand.PlusUpgrade, (src?: Source) => this.upgrade(src)), - registerCommand(Commands.PlusHide, (src?: Source) => this.setProFeaturesVisibility(false, src)), - registerCommand(Commands.PlusRestore, (src?: Source) => this.setProFeaturesVisibility(true, src)), + registerCommand(GlCommand.PlusHide, (src?: Source) => this.setProFeaturesVisibility(false, src)), + registerCommand(GlCommand.PlusRestore, (src?: Source) => this.setProFeaturesVisibility(true, src)), - registerCommand(Commands.PlusValidate, (src?: Source) => this.validate({ force: true }, src)), + registerCommand(GlCommand.PlusValidate, (src?: Source) => this.validate({ force: true }, src)), - registerCommand(Commands.PlusContinueFeaturePreview, ({ feature }: { feature: FeaturePreviews }) => + registerCommand(GlCommand.PlusContinueFeaturePreview, ({ feature }: { feature: FeaturePreviews }) => this.continueFeaturePreview(feature), ), ]; @@ -435,14 +435,14 @@ export class SubscriptionService implements Disposable { switch (subscription.state) { case SubscriptionState.VerificationRequired: case SubscriptionState.Community: - void executeCommand(Commands.OpenWalkthrough, { + void executeCommand(GlCommand.OpenWalkthrough, { ...source, step: 'get-started-community', }); break; case SubscriptionState.ProTrial: case SubscriptionState.ProPreview: - void executeCommand(Commands.OpenWalkthrough, { + void executeCommand(GlCommand.OpenWalkthrough, { ...source, step: 'welcome-in-trial', }); @@ -450,13 +450,13 @@ export class SubscriptionService implements Disposable { case SubscriptionState.ProTrialReactivationEligible: case SubscriptionState.ProTrialExpired: case SubscriptionState.ProPreviewExpired: - void executeCommand(Commands.OpenWalkthrough, { + void executeCommand(GlCommand.OpenWalkthrough, { ...source, step: 'welcome-in-trial-expired', }); break; case SubscriptionState.Paid: - void executeCommand(Commands.OpenWalkthrough, { + void executeCommand(GlCommand.OpenWalkthrough, { ...source, step: 'welcome-paid', }); @@ -796,7 +796,7 @@ export class SubscriptionService implements Disposable { if (silent && !configuration.get('plusFeatures.enabled', undefined, true)) return; if (!this.container.views.home.visible) { - await executeCommand(Commands.ShowAccountView); + await executeCommand(GlCommand.ShowAccountView); } } @@ -1549,7 +1549,7 @@ export class SubscriptionService implements Disposable { this._statusBarSubscription.name = 'GitLens Pro'; this._statusBarSubscription.text = '$(gitlens-gitlens)'; - this._statusBarSubscription.command = Commands.ShowAccountView; + this._statusBarSubscription.command = GlCommand.ShowAccountView; this._statusBarSubscription.backgroundColor = undefined; if (account?.verified === false) { diff --git a/src/plus/launchpad/launchpad.ts b/src/plus/launchpad/launchpad.ts index 44c548088467f..2eedeb7915a59 100644 --- a/src/plus/launchpad/launchpad.ts +++ b/src/plus/launchpad/launchpad.ts @@ -35,7 +35,7 @@ import { import { ensureAccessStep } from '../../commands/quickCommand.steps'; import type { OpenWalkthroughCommandArgs } from '../../commands/walkthroughs'; import { proBadge, urls } from '../../constants'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import type { IntegrationId } from '../../constants.integrations'; import { HostingIntegrationId, SelfHostedIntegrationId } from '../../constants.integrations'; import type { LaunchpadTelemetryContext, Source, Sources, TelemetryEvents } from '../../constants.telemetry'; @@ -1035,7 +1035,7 @@ export class LaunchpadCommand extends QuickCommand { detail: 'Click to learn more about Launchpad', iconPath: new ThemeIcon('rocket'), onDidSelect: () => - void executeCommand(Commands.OpenWalkthrough, { + void executeCommand(GlCommand.OpenWalkthrough, { step: 'accelerate-pr-reviews', source: 'launchpad', detail: 'info', @@ -1111,7 +1111,7 @@ export class LaunchpadCommand extends QuickCommand { detail: 'Click to learn more about Launchpad', iconPath: new ThemeIcon('rocket'), onDidSelect: () => - void executeCommand(Commands.OpenWalkthrough, { + void executeCommand(GlCommand.OpenWalkthrough, { step: 'accelerate-pr-reviews', source: 'launchpad', detail: 'info', diff --git a/src/plus/launchpad/launchpadIndicator.ts b/src/plus/launchpad/launchpadIndicator.ts index f795086932d32..25d6c73e17f6b 100644 --- a/src/plus/launchpad/launchpadIndicator.ts +++ b/src/plus/launchpad/launchpadIndicator.ts @@ -3,7 +3,7 @@ import { Disposable, MarkdownString, StatusBarAlignment, ThemeColor, window } fr import type { OpenWalkthroughCommandArgs } from '../../commands/walkthroughs'; import { proBadge } from '../../constants'; import type { Colors } from '../../constants.colors'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import type { HostingIntegrationId } from '../../constants.integrations'; import type { Container } from '../../container'; import { groupByMap } from '../../system/iterable'; @@ -308,7 +308,7 @@ export class LaunchpadIndicator implements Disposable { const labelType = configuration.get('launchpad.indicator.label') ?? 'item'; this._statusBarLaunchpad.command = { title: 'Open Launchpad', - command: Commands.ShowLaunchpad, + command: GlCommand.ShowLaunchpad, arguments: [ { source: 'launchpad-indicator', @@ -540,7 +540,7 @@ export class LaunchpadIndicator implements Disposable { this.storeFirstInteractionIfNeeded(); switch (action) { case 'info': { - void executeCommand(Commands.OpenWalkthrough, { + void executeCommand(GlCommand.OpenWalkthrough, { step: 'accelerate-pr-reviews', source: 'launchpad-indicator', detail: 'info', diff --git a/src/plus/launchpad/launchpadProvider.ts b/src/plus/launchpad/launchpadProvider.ts index a22d3bc9c337c..6e40000565adc 100644 --- a/src/plus/launchpad/launchpadProvider.ts +++ b/src/plus/launchpad/launchpadProvider.ts @@ -6,7 +6,7 @@ import type { } from '@gitkraken/provider-apis'; import type { CancellationToken, ConfigurationChangeEvent } from 'vscode'; import { Disposable, env, EventEmitter, Uri, window } from 'vscode'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import type { IntegrationId } from '../../constants.integrations'; import { HostingIntegrationId } from '../../constants.integrations'; import type { Container } from '../../container'; @@ -500,7 +500,7 @@ export class LaunchpadProvider implements Disposable { if (draft == null) return; this._codeSuggestions?.delete(item.uuid); this._prs = undefined; - void executeCommand(Commands.OpenCloudPatch, { + void executeCommand(GlCommand.OpenCloudPatch, { type: 'code_suggestion', draft: draft, }); @@ -944,7 +944,7 @@ export class LaunchpadProvider implements Disposable { private registerCommands(): Disposable[] { return [ - registerCommand(Commands.ToggleLaunchpadIndicator, () => { + registerCommand(GlCommand.ToggleLaunchpadIndicator, () => { const enabled = configuration.get('launchpad.indicator.enabled') ?? false; void configuration.updateEffective('launchpad.indicator.enabled', !enabled); }), diff --git a/src/plus/startWork/startWork.ts b/src/plus/startWork/startWork.ts index 6b817154893bc..9bec844d2cdfb 100644 --- a/src/plus/startWork/startWork.ts +++ b/src/plus/startWork/startWork.ts @@ -25,7 +25,7 @@ import { } from '../../commands/quickCommand.buttons'; import { getSteps } from '../../commands/quickWizard.utils'; import { proBadge } from '../../constants'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import type { IntegrationId } from '../../constants.integrations'; import { HostingIntegrationId, IssueIntegrationId } from '../../constants.integrations'; import type { Source, Sources, StartWorkTelemetryContext, TelemetryEvents } from '../../constants.telemetry'; @@ -492,7 +492,7 @@ export class StartWorkCommand extends QuickCommand { return StepResultBreak; } else if (isManageIntegrationsItem(element)) { this.sendActionTelemetry('manage', context); - executeCommand(Commands.PlusManageCloudIntegrations, { source: 'startWork' }); + executeCommand(GlCommand.PlusManageCloudIntegrations, { source: 'startWork' }); endSteps(state); return StepResultBreak; } diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index 970a0552cd1d3..308ea5ba0ae08 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -18,7 +18,7 @@ import type { GraphScrollMarkersAdditionalTypes, } from '../../../config'; import { GlyphChars } from '../../../constants'; -import { Commands } from '../../../constants.commands'; +import { GlCommand } from '../../../constants.commands'; import type { StoredGraphFilters, StoredGraphRefType } from '../../../constants.storage'; import type { GraphShownTelemetryContext, GraphTelemetryContext, TelemetryEvents } from '../../../constants.telemetry'; import type { Container } from '../../../container'; @@ -313,7 +313,7 @@ export class GraphWebviewProvider implements WebviewProvider, ) { this._showDetailsView = configuration.get('graph.showDetailsView'); this._theme = window.activeColorTheme; @@ -452,7 +452,7 @@ export class GraphWebviewProvider implements WebviewProvider 1) { - const [contexts] = parseCommandContext(Commands.ShowGraph, undefined, ...args); + const [contexts] = parseCommandContext(GlCommand.ShowGraph, undefined, ...args); const context = Array.isArray(contexts) ? contexts[0] : contexts; if (context.type === 'scm' && context.scm.rootUri != null) { @@ -490,7 +490,7 @@ export class GraphWebviewProvider implements WebviewProvider void executeCommand( - Commands.ShowGraphPage, + GlCommand.ShowGraphPage, undefined, this.repository, ), @@ -3054,7 +3054,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.OpenOnRemote, { + return executeCommand(GlCommand.OpenOnRemote, { repoPath: ref.repoPath, resource: { type: RemoteResourceType.Branch, @@ -3150,7 +3150,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.CopyMessageToClipboard, { + return executeCommand(GlCommand.CopyMessageToClipboard, { repoPath: ref.repoPath, sha: ref.ref, message: 'message' in ref ? ref.message : undefined, @@ -3167,7 +3167,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.CopyShaToClipboard, { + return executeCommand(GlCommand.CopyShaToClipboard, { sha: sha, }); } @@ -3181,7 +3181,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.ShowInDetailsView, { ref: ref }); + return executeCommand(GlCommand.ShowInDetailsView, { ref: ref }); } @log() @@ -3204,7 +3204,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.OpenOnRemote, { + return executeCommand(GlCommand.OpenOnRemote, { repoPath: selection[0].repoPath, resource: selection.map(r => ({ type: RemoteResourceType.Commit, sha: r.ref })), clipboard: clipboard, @@ -3215,7 +3215,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.CopyDeepLinkToBranch, { refOrRepoPath: ref }); + return executeCommand(GlCommand.CopyDeepLinkToBranch, { refOrRepoPath: ref }); } return Promise.resolve(); @@ -3226,7 +3226,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.CopyDeepLinkToCommit, { refOrRepoPath: ref }); + return executeCommand(GlCommand.CopyDeepLinkToCommit, { refOrRepoPath: ref }); } @log() @@ -3235,7 +3235,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.CopyDeepLinkToRepo, { + return executeCommand(GlCommand.CopyDeepLinkToRepo, { refOrRepoPath: ref.repoPath, remote: getRemoteNameFromBranchName(ref.name), }); @@ -3248,7 +3248,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.CopyDeepLinkToTag, { refOrRepoPath: ref }); + return executeCommand(GlCommand.CopyDeepLinkToTag, { refOrRepoPath: ref }); } return Promise.resolve(); @@ -3261,7 +3261,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.CreateCloudPatch, { + return executeCommand(GlCommand.CreateCloudPatch, { to: ref.ref, repoPath: ref.repoPath, title: title, @@ -3527,7 +3527,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.OpenPullRequestOnRemote, { + return executeCommand(GlCommand.OpenPullRequestOnRemote, { pr: { url: url }, clipboard: clipboard, }); @@ -3642,7 +3642,7 @@ export class GraphWebviewProvider implements WebviewProvider(Commands.GenerateCommitMessage, { + return executeCommand(GlCommand.GenerateCommitMessage, { repoPath: ref.repoPath, }); } diff --git a/src/plus/webviews/graph/registration.ts b/src/plus/webviews/graph/registration.ts index dc8ab0ef2cd26..03b26dba7288e 100644 --- a/src/plus/webviews/graph/registration.ts +++ b/src/plus/webviews/graph/registration.ts @@ -1,6 +1,6 @@ import { Disposable, ViewColumn } from 'vscode'; import { isScm } from '../../../commands/base'; -import { Commands } from '../../../constants.commands'; +import { GlCommand } from '../../../constants.commands'; import type { Container } from '../../../container'; import type { GitReference } from '../../../git/models/reference'; import type { Repository } from '../../../git/models/repository'; @@ -24,8 +24,8 @@ import type { ShowInCommitGraphCommandArgs, State } from './protocol'; export type GraphWebviewShowingArgs = [Repository | { ref: GitReference }]; export function registerGraphWebviewPanel(controller: WebviewsController) { - return controller.registerWebviewPanel( - { id: Commands.ShowGraphPage, options: { preserveInstance: true } }, + return controller.registerWebviewPanel<'gitlens.graph', State, State, GraphWebviewShowingArgs>( + { id: GlCommand.ShowGraphPage, options: { preserveInstance: true } }, { id: 'gitlens.graph', fileName: 'graph.html', @@ -50,7 +50,7 @@ export function registerGraphWebviewPanel(controller: WebviewsController) { } export function registerGraphWebviewView(controller: WebviewsController) { - return controller.registerWebviewView( + return controller.registerWebviewView<'gitlens.views.graph', State, State, GraphWebviewShowingArgs>( { id: 'gitlens.views.graph', fileName: 'graph.html', @@ -72,10 +72,10 @@ export function registerGraphWebviewView(controller: WebviewsController) { export function registerGraphWebviewCommands( container: Container, - panels: WebviewPanelsProxy, + panels: WebviewPanelsProxy<'gitlens.graph', GraphWebviewShowingArgs, T>, ) { return Disposable.from( - registerCommand(Commands.ShowGraph, (...args: unknown[]) => { + registerCommand(GlCommand.ShowGraph, (...args: unknown[]) => { const [arg] = args; let showInGraphArg; @@ -95,44 +95,44 @@ export function registerGraphWebviewCommands( } if (showInGraphArg != null) { - return executeCommand(Commands.ShowInCommitGraph, showInGraphArg); + return executeCommand(GlCommand.ShowInCommitGraph, showInGraphArg); } if (configuration.get('graph.layout') === 'panel') { - return executeCommand(Commands.ShowGraphView, ...args); + return executeCommand(GlCommand.ShowGraphView, ...args); } - return executeCommand(Commands.ShowGraphPage, undefined, ...args); + return executeCommand(GlCommand.ShowGraphPage, undefined, ...args); }), registerCommand(`${panels.id}.switchToEditorLayout`, async () => { await configuration.updateEffective('graph.layout', 'editor'); - queueMicrotask(() => void executeCommand(Commands.ShowGraphPage)); + queueMicrotask(() => void executeCommand(GlCommand.ShowGraphPage)); }), registerCommand(`${panels.id}.switchToPanelLayout`, async () => { await configuration.updateEffective('graph.layout', 'panel'); queueMicrotask(async () => { await executeCoreCommand('gitlens.views.graph.resetViewLocation'); await executeCoreCommand('gitlens.views.graphDetails.resetViewLocation'); - void executeCommand(Commands.ShowGraphView); + void executeCommand(GlCommand.ShowGraphView); }); }), - registerCommand(Commands.ToggleGraph, (...args: any[]) => { + registerCommand(GlCommand.ToggleGraph, (...args: any[]) => { if (getContext('gitlens:webviewView:graph:visible')) { void executeCoreCommand('workbench.action.closePanel'); } else { - void executeCommand(Commands.ShowGraphView, ...args); + void executeCommand(GlCommand.ShowGraphView, ...args); } }), - registerCommand(Commands.ToggleMaximizedGraph, (...args: any[]) => { + registerCommand(GlCommand.ToggleMaximizedGraph, (...args: any[]) => { if (getContext('gitlens:webviewView:graph:visible')) { void executeCoreCommand('workbench.action.toggleMaximizedPanel'); } else { - void executeCommand(Commands.ShowGraphView, ...args); + void executeCommand(GlCommand.ShowGraphView, ...args); void executeCoreCommand('workbench.action.toggleMaximizedPanel'); } }), registerCommand( - Commands.ShowInCommitGraph, + GlCommand.ShowInCommitGraph, ( args: | ShowInCommitGraphCommandArgs @@ -167,7 +167,7 @@ export function registerGraphWebviewCommands( }, ), registerCommand( - Commands.ShowInCommitGraphView, + GlCommand.ShowInCommitGraphView, ( args: | ShowInCommitGraphCommandArgs diff --git a/src/plus/webviews/graph/statusbar.ts b/src/plus/webviews/graph/statusbar.ts index afe287885c3ba..bcbb01bda9f01 100644 --- a/src/plus/webviews/graph/statusbar.ts +++ b/src/plus/webviews/graph/statusbar.ts @@ -1,6 +1,6 @@ import type { ConfigurationChangeEvent, StatusBarItem } from 'vscode'; import { Disposable, MarkdownString, StatusBarAlignment, window } from 'vscode'; -import { Commands } from '../../../constants.commands'; +import { GlCommand } from '../../../constants.commands'; import type { Container } from '../../../container'; import { once } from '../../../system/function'; import { configuration } from '../../../system/vscode/configuration'; @@ -46,7 +46,7 @@ export class GraphStatusBarController implements Disposable { if (this._statusBarItem == null) { this._statusBarItem = window.createStatusBarItem('gitlens.graph', StatusBarAlignment.Left, 10000 - 2); this._statusBarItem.name = 'GitLens Commit Graph'; - this._statusBarItem.command = Commands.ShowGraph; + this._statusBarItem.command = GlCommand.ShowGraph; this._statusBarItem.text = '$(gitlens-graph)'; this._statusBarItem.tooltip = new MarkdownString('Visualize commits on the Commit Graph'); this._statusBarItem.accessibilityInformation = { diff --git a/src/plus/webviews/patchDetails/patchDetailsWebview.ts b/src/plus/webviews/patchDetails/patchDetailsWebview.ts index a41ae40ea9d8b..7e7302751f455 100644 --- a/src/plus/webviews/patchDetails/patchDetailsWebview.ts +++ b/src/plus/webviews/patchDetails/patchDetailsWebview.ts @@ -2,7 +2,7 @@ import type { ConfigurationChangeEvent } from 'vscode'; import { Disposable, env, Uri, window } from 'vscode'; import { getAvatarUri } from '../../../avatars'; import { GlyphChars, previewBadge } from '../../../constants'; -import { Commands } from '../../../constants.commands'; +import { GlCommand } from '../../../constants.commands'; import type { ContextKeys } from '../../../constants.context'; import type { Sources, WebviewTelemetryContext } from '../../../constants.telemetry'; import type { Container } from '../../../container'; @@ -134,7 +134,7 @@ export class PatchDetailsWebviewProvider constructor( private readonly container: Container, - private readonly host: WebviewHost, + private readonly host: WebviewHost<'gitlens.views.patchDetails' | 'gitlens.patchDetails'>, ) { this._context = { mode: 'create', @@ -267,7 +267,7 @@ export class PatchDetailsWebviewProvider break; case OpenInCommitGraphCommand.is(e): - void executeCommand(Commands.ShowInCommitGraph, { + void executeCommand(GlCommand.ShowInCommitGraph, { ref: createReference(e.params.ref, e.params.repoPath, { refType: 'revision' }), }); break; diff --git a/src/plus/webviews/patchDetails/registration.ts b/src/plus/webviews/patchDetails/registration.ts index 2c4fc677c7ef6..e33f25a348f9d 100644 --- a/src/plus/webviews/patchDetails/registration.ts +++ b/src/plus/webviews/patchDetails/registration.ts @@ -1,5 +1,5 @@ import { ViewColumn } from 'vscode'; -import { Commands } from '../../../constants.commands'; +import { GlCommand } from '../../../constants.commands'; import type { Sources } from '../../../constants.telemetry'; import { executeCommand } from '../../../system/vscode/command'; import { configuration } from '../../../system/vscode/configuration'; @@ -23,7 +23,12 @@ export type ShowViewDraft = { export type PatchDetailsWebviewShowingArgs = [ShowCreateDraft | ShowViewDraft]; export function registerPatchDetailsWebviewView(controller: WebviewsController) { - return controller.registerWebviewView, PatchDetailsWebviewShowingArgs>( + return controller.registerWebviewView< + 'gitlens.views.patchDetails', + State, + Serialized, + PatchDetailsWebviewShowingArgs + >( { id: 'gitlens.views.patchDetails', fileName: 'patchDetails.html', @@ -45,7 +50,7 @@ export function registerPatchDetailsWebviewView(controller: WebviewsController) async (...args) => { if (configuration.get('cloudPatches.experimental.layout') === 'editor') { await setContext('gitlens:views:patchDetails:mode', undefined); - void executeCommand(Commands.ShowPatchDetailsPage, undefined, ...args); + void executeCommand(GlCommand.ShowPatchDetailsPage, undefined, ...args); return; } @@ -58,8 +63,13 @@ export function registerPatchDetailsWebviewView(controller: WebviewsController) } export function registerPatchDetailsWebviewPanel(controller: WebviewsController) { - return controller.registerWebviewPanel, PatchDetailsWebviewShowingArgs>( - { id: Commands.ShowPatchDetailsPage, options: { preserveInstance: true } }, + return controller.registerWebviewPanel< + 'gitlens.patchDetails', + State, + Serialized, + PatchDetailsWebviewShowingArgs + >( + { id: GlCommand.ShowPatchDetailsPage, options: { preserveInstance: true } }, { id: 'gitlens.patchDetails', fileName: 'patchDetails.html', diff --git a/src/plus/webviews/timeline/registration.ts b/src/plus/webviews/timeline/registration.ts index f8f065f130b87..def291bedf73e 100644 --- a/src/plus/webviews/timeline/registration.ts +++ b/src/plus/webviews/timeline/registration.ts @@ -1,6 +1,6 @@ import type { Uri } from 'vscode'; import { Disposable, ViewColumn } from 'vscode'; -import { Commands } from '../../../constants.commands'; +import { GlCommand } from '../../../constants.commands'; import { registerCommand } from '../../../system/vscode/command'; import { configuration } from '../../../system/vscode/configuration'; import type { ViewFileNode } from '../../../views/nodes/abstract/viewFileNode'; @@ -10,8 +10,8 @@ import type { State } from './protocol'; export type TimelineWebviewShowingArgs = [Uri | ViewFileNode]; export function registerTimelineWebviewPanel(controller: WebviewsController) { - return controller.registerWebviewPanel( - { id: Commands.ShowTimelinePage, options: { preserveInstance: true } }, + return controller.registerWebviewPanel<'gitlens.timeline', State, State, TimelineWebviewShowingArgs>( + { id: GlCommand.ShowTimelinePage, options: { preserveInstance: true } }, { id: 'gitlens.timeline', fileName: 'timeline.html', @@ -38,7 +38,7 @@ export function registerTimelineWebviewPanel(controller: WebviewsController) { } export function registerTimelineWebviewView(controller: WebviewsController) { - return controller.registerWebviewView( + return controller.registerWebviewView<'gitlens.views.timeline', State, State, TimelineWebviewShowingArgs>( { id: 'gitlens.views.timeline', fileName: 'timeline.html', @@ -60,10 +60,12 @@ export function registerTimelineWebviewView(controller: WebviewsController) { ); } -export function registerTimelineWebviewCommands(panels: WebviewPanelsProxy) { +export function registerTimelineWebviewCommands( + panels: WebviewPanelsProxy<'gitlens.timeline', TimelineWebviewShowingArgs, T>, +) { return Disposable.from( registerCommand( - Commands.ShowInTimeline, + GlCommand.ShowInTimeline, (...args: TimelineWebviewShowingArgs) => void panels.show(undefined, ...args), ), registerCommand(`${panels.id}.refresh`, () => void panels.getActiveInstance()?.refresh(true)), diff --git a/src/plus/webviews/timeline/timelineWebview.ts b/src/plus/webviews/timeline/timelineWebview.ts index 54baad57b48d9..9a12a1e4ff11e 100644 --- a/src/plus/webviews/timeline/timelineWebview.ts +++ b/src/plus/webviews/timeline/timelineWebview.ts @@ -1,7 +1,7 @@ import type { TextEditor } from 'vscode'; import { Disposable, Uri, window } from 'vscode'; import { proBadge } from '../../../constants'; -import { Commands } from '../../../constants.commands'; +import { GlCommand } from '../../../constants.commands'; import type { TimelineShownTelemetryContext, TimelineTelemetryContext } from '../../../constants.telemetry'; import type { Container } from '../../../container'; import type { CommitSelectedEvent, FileSelectedEvent } from '../../../eventBus'; @@ -51,7 +51,7 @@ export class TimelineWebviewProvider implements WebviewProvider, ) { this._context = { uri: undefined, @@ -179,7 +179,7 @@ export class TimelineWebviewProvider implements WebviewProvider { if (this._context.uri == null) return; - void executeCommand(Commands.ShowInTimeline, this._context.uri); + void executeCommand(GlCommand.ShowInTimeline, this._context.uri); this.container.telemetry.sendEvent('timeline/action/openInEditor', this.getTelemetryContext()); }, this, diff --git a/src/quickpicks/aiModelPicker.ts b/src/quickpicks/aiModelPicker.ts index f75fad128ec2e..fb30ea94bc429 100644 --- a/src/quickpicks/aiModelPicker.ts +++ b/src/quickpicks/aiModelPicker.ts @@ -2,7 +2,7 @@ import type { Disposable, QuickInputButton, QuickPickItem } from 'vscode'; import { QuickPickItemKind, ThemeIcon, window } from 'vscode'; import type { AIModel } from '../ai/aiProviderService'; import type { AIModels, AIProviders } from '../constants.ai'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeCommand } from '../system/vscode/command'; import { getQuickPickIgnoreFocusOut } from '../system/vscode/utils'; @@ -60,7 +60,7 @@ export async function showAIModelPicker( }), quickpick.onDidTriggerButton(e => { if (e === ResetAIKeyButton) { - void executeCommand(Commands.ResetAIKey); + void executeCommand(GlCommand.ResetAIKey); } }), ); diff --git a/src/quickpicks/items/commits.ts b/src/quickpicks/items/commits.ts index ad52da909b834..9d42b472f62f5 100644 --- a/src/quickpicks/items/commits.ts +++ b/src/quickpicks/items/commits.ts @@ -4,7 +4,7 @@ import type { OpenOnlyChangedFilesCommandArgs } from '../../commands/openOnlyCha import { RevealInSideBarQuickInputButton, ShowDetailsViewQuickInputButton } from '../../commands/quickCommand.buttons'; import type { Keys } from '../../constants'; import { GlyphChars } from '../../constants'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import { Container } from '../../container'; import { browseAtRevision } from '../../git/actions'; import * as CommitActions from '../../git/actions/commit'; @@ -370,7 +370,7 @@ export class OpenChangedFilesCommandQuickPickItem extends CommandQuickPickItem { uris: files.map(f => f.uri), }; - super(label ?? 'Open All Changed Files', new ThemeIcon('files'), Commands.OpenChangedFiles, [commandArgs]); + super(label ?? 'Open All Changed Files', new ThemeIcon('files'), GlCommand.OpenChangedFiles, [commandArgs]); } } @@ -380,7 +380,7 @@ export class OpenOnlyChangedFilesCommandQuickPickItem extends CommandQuickPickIt uris: files.map(f => f.uri), }; - super(label ?? 'Open Changed & Close Unchanged Files', new ThemeIcon('files'), Commands.OpenOnlyChangedFiles, [ + super(label ?? 'Open Changed & Close Unchanged Files', new ThemeIcon('files'), GlCommand.OpenOnlyChangedFiles, [ commandArgs, ]); } diff --git a/src/quickpicks/items/common.ts b/src/quickpicks/items/common.ts index a30600608d11a..2a409d45a3d93 100644 --- a/src/quickpicks/items/common.ts +++ b/src/quickpicks/items/common.ts @@ -1,7 +1,7 @@ import type { QuickPickItem, ThemeIcon, Uri } from 'vscode'; import { commands, QuickPickItemKind } from 'vscode'; import type { Keys } from '../../constants'; -import type { Commands } from '../../constants.commands'; +import type { GlCommands } from '../../constants.commands'; declare module 'vscode' { interface QuickPickItem { @@ -27,9 +27,9 @@ export function createQuickPickItemOfT(labelOrItem: string | QuickPickI } export class CommandQuickPickItem implements QuickPickItem { - static fromCommand(label: string, command: Commands, args?: T): CommandQuickPickItem; - static fromCommand(item: QuickPickItem, command: Commands, args?: T): CommandQuickPickItem; - static fromCommand(labelOrItem: string | QuickPickItem, command: Commands, args?: T): CommandQuickPickItem { + static fromCommand(label: string, command: GlCommands, args?: T): CommandQuickPickItem; + static fromCommand(item: QuickPickItem, command: GlCommands, args?: T): CommandQuickPickItem; + static fromCommand(labelOrItem: string | QuickPickItem, command: GlCommands, args?: T): CommandQuickPickItem { return new CommandQuickPickItem( typeof labelOrItem === 'string' ? { label: labelOrItem } : labelOrItem, undefined, @@ -50,7 +50,7 @@ export class CommandQuickPickItem implements Qu constructor( label: string, iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon | undefined, - command?: Commands, + command?: GlCommands, args?: Arguments, options?: { onDidPressKey?: (key: Keys, result: Thenable) => void; @@ -60,7 +60,7 @@ export class CommandQuickPickItem implements Qu constructor( item: QuickPickItem, iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon | undefined, - command?: Commands, + command?: GlCommands, args?: Arguments, options?: { onDidPressKey?: (key: Keys, result: Thenable) => void; @@ -70,7 +70,7 @@ export class CommandQuickPickItem implements Qu constructor( labelOrItem: string | QuickPickItem, iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon | undefined, - command?: Commands, + command?: GlCommands, args?: Arguments, options?: { onDidPressKey?: (key: Keys, result: Thenable) => void; @@ -80,7 +80,7 @@ export class CommandQuickPickItem implements Qu constructor( labelOrItem: string | QuickPickItem, iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon | undefined, - protected readonly command?: Commands, + protected readonly command?: GlCommands, protected readonly args?: Arguments, protected readonly options?: { // onDidExecute?: ( diff --git a/src/quickpicks/items/gitWizard.ts b/src/quickpicks/items/gitWizard.ts index 182e437f8887a..e39d342b646a8 100644 --- a/src/quickpicks/items/gitWizard.ts +++ b/src/quickpicks/items/gitWizard.ts @@ -3,7 +3,7 @@ import { ThemeIcon } from 'vscode'; import type { GitWizardCommandArgs } from '../../commands/gitWizard'; import { getSteps } from '../../commands/quickWizard.utils'; import { GlyphChars } from '../../constants'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import { Container } from '../../container'; import { emojify } from '../../emojis'; import type { GitBranch } from '../../git/models/branch'; @@ -27,7 +27,7 @@ export class GitWizardQuickPickItem extends CommandQuickPickItem<[GitWizardComma constructor(label: string, args: GitWizardCommandArgs); constructor(item: QuickPickItem, args: GitWizardCommandArgs); constructor(labelOrItem: string | QuickPickItem, args: GitWizardCommandArgs) { - super(labelOrItem, undefined, Commands.GitCommands, [args], { suppressKeyPress: true }); + super(labelOrItem, undefined, GlCommand.GitCommands, [args], { suppressKeyPress: true }); } executeSteps(pickedVia: 'menu' | 'command') { diff --git a/src/quickpicks/remoteProviderPicker.ts b/src/quickpicks/remoteProviderPicker.ts index 633f9bbac7e56..268a282663155 100644 --- a/src/quickpicks/remoteProviderPicker.ts +++ b/src/quickpicks/remoteProviderPicker.ts @@ -4,7 +4,7 @@ import type { OpenOnRemoteCommandArgs } from '../commands/openOnRemote'; import { SetRemoteAsDefaultQuickInputButton } from '../commands/quickCommand.buttons'; import type { Keys } from '../constants'; import { GlyphChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import { Container } from '../container'; import { getBranchNameWithoutRemote, getDefaultBranchName, getRemoteNameFromBranchName } from '../git/models/branch'; import type { GitRemote } from '../git/models/remote'; @@ -114,7 +114,7 @@ export class CopyRemoteResourceCommandQuickPickItem extends CommandQuickPickItem const label = `Copy Link to ${getNameFromRemoteResource(resource)} for ${ providers?.length ? providers[0].name : 'Remote' }${providers?.length === 1 ? '' : GlyphChars.Ellipsis}`; - super(label, new ThemeIcon('copy'), Commands.OpenOnRemote, [commandArgs]); + super(label, new ThemeIcon('copy'), GlCommand.OpenOnRemote, [commandArgs]); } override async onDidPressKey(key: Keys): Promise { @@ -138,7 +138,7 @@ export class OpenRemoteResourceCommandQuickPickItem extends CommandQuickPickItem : `${providers?.length ? providers[0].name : 'Remote'}${GlyphChars.Ellipsis}` }`, new ThemeIcon('link-external'), - Commands.OpenOnRemote, + GlCommand.OpenOnRemote, [commandArgs], ); } diff --git a/src/statusbar/statusBarController.ts b/src/statusbar/statusBarController.ts index 82fcf56d4550f..54d0466fb5373 100644 --- a/src/statusbar/statusBarController.ts +++ b/src/statusbar/statusBarController.ts @@ -3,7 +3,7 @@ import { CancellationTokenSource, Disposable, MarkdownString, StatusBarAlignment import type { ToggleFileChangesAnnotationCommandArgs } from '../commands/toggleFileAnnotations'; import { StatusBarCommand } from '../config'; import { GlyphChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { CommitFormatter } from '../git/formatters/commitFormatter'; import type { PullRequest } from '../git/models/pullRequest'; @@ -72,7 +72,7 @@ export class StatusBarController implements Disposable { alignment === StatusBarAlignment.Right ? 999 : 1, ); this._statusBarMode.name = 'GitLens Modes'; - this._statusBarMode.command = Commands.SwitchMode; + this._statusBarMode.command = GlCommand.SwitchMode; this._statusBarMode.text = mode.statusBarItemName; this._statusBarMode.tooltip = new MarkdownString( `**${mode.statusBarItemName}** ${GlyphChars.Dash} ${mode.description}\n\n---\n\nClick to Switch GitLens Modes`, @@ -167,14 +167,14 @@ export class StatusBarController implements Disposable { if (!status?.blameable) return; statusBarItem.tooltip = new MarkdownString(); - statusBarItem.tooltip.isTrusted = { enabledCommands: [Commands.ShowSettingsPage] }; + statusBarItem.tooltip.isTrusted = { enabledCommands: [GlCommand.ShowSettingsPage] }; if (doc.canDirtyIdle) { statusBarItem.text = '$(watch) Blame Paused'; statusBarItem.tooltip.appendMarkdown( `Blame will resume after a [${configuration.get( 'advanced.blame.delayAfterEdit', - )} ms delay](${createMarkdownCommandLink<[undefined, string]>(Commands.ShowSettingsPage, [ + )} ms delay](${createMarkdownCommandLink<[undefined, string]>(GlCommand.ShowSettingsPage, [ undefined, 'advanced.blame.delayAfterEdit', ])} 'Change the after edit delay') to limit the performance impact because there are unsaved changes`, @@ -185,7 +185,7 @@ export class StatusBarController implements Disposable { `Blame will resume after saving because there are unsaved changes and the file is over the [${configuration.get( 'advanced.blame.sizeThresholdAfterEdit', )} line threshold](${createMarkdownCommandLink<[undefined, string]>( - Commands.ShowSettingsPage, + GlCommand.ShowSettingsPage, [undefined, 'advanced.blame.sizeThresholdAfterEdit'], )} 'Change the after edit line threshold') to limit the performance impact`, ); @@ -256,15 +256,15 @@ export class StatusBarController implements Disposable { actionTooltip = 'Click to Copy Remote Commit URL'; break; case StatusBarCommand.CopyRemoteFileUrl: - this._statusBarBlame.command = Commands.CopyRemoteFileUrl; + this._statusBarBlame.command = GlCommand.CopyRemoteFileUrl; actionTooltip = 'Click to Copy Remote File Revision URL'; break; case StatusBarCommand.DiffWithPrevious: - this._statusBarBlame.command = Commands.DiffLineWithPrevious; + this._statusBarBlame.command = GlCommand.DiffLineWithPrevious; actionTooltip = 'Click to Open Line Changes with Previous Revision'; break; case StatusBarCommand.DiffWithWorking: - this._statusBarBlame.command = Commands.DiffLineWithWorking; + this._statusBarBlame.command = GlCommand.DiffLineWithWorking; actionTooltip = 'Click to Open Line Changes with Working File'; break; case StatusBarCommand.OpenCommitOnRemote: @@ -300,7 +300,7 @@ export class StatusBarController implements Disposable { case StatusBarCommand.ToggleFileChanges: { if (commit.file != null) { this._statusBarBlame.command = createCommand<[Uri, ToggleFileChangesAnnotationCommandArgs]>( - Commands.ToggleFileChanges, + GlCommand.ToggleFileChanges, 'Toggle File Changes', commit.file.uri, { @@ -315,7 +315,7 @@ export class StatusBarController implements Disposable { case StatusBarCommand.ToggleFileChangesOnly: { if (commit.file != null) { this._statusBarBlame.command = createCommand<[Uri, ToggleFileChangesAnnotationCommandArgs]>( - Commands.ToggleFileChanges, + GlCommand.ToggleFileChanges, 'Toggle File Changes', commit.file.uri, { diff --git a/src/system/commands.ts b/src/system/commands.ts index 2ea3e4d71c740..992383e013f30 100644 --- a/src/system/commands.ts +++ b/src/system/commands.ts @@ -1,12 +1,12 @@ -import type { Commands, CustomViewCommands, TreeViewCommands } from '../constants.commands'; +import type { Commands } from '../constants.commands'; -export function createCommandLink(command: Commands | TreeViewCommands | CustomViewCommands, args: T) { +export function createCommandLink(command: Commands, args?: T) { if (args == null) return `command:${command}`; return `command:${command}?${encodeURIComponent(typeof args === 'string' ? args : JSON.stringify(args))}`; } -export function createMarkdownCommandLink(command: Commands | TreeViewCommands, args: T): string { +export function createMarkdownCommandLink(command: Commands, args: T): string { if (args == null) return `command:${command}`; // Since we are using the command in a markdown link, we need to escape ()'s so they don't get interpreted as markdown diff --git a/src/system/vscode/command.ts b/src/system/vscode/command.ts index d3680a1e65e82..09dc44f03f733 100644 --- a/src/system/vscode/command.ts +++ b/src/system/vscode/command.ts @@ -1,16 +1,16 @@ -import type { Disposable, Command as ICommand, Uri } from 'vscode'; +import type { Command, Disposable, Uri } from 'vscode'; import { commands } from 'vscode'; import type { Action, ActionContext } from '../../api/gitlens'; -import type { Command } from '../../commands/base'; +import type { GlCommandBase } from '../../commands/base'; import type { CodeLensCommand } from '../../config'; -import type { CoreCommands, CoreGitCommands, TreeViewCommands } from '../../constants.commands'; -import { Commands } from '../../constants.commands'; +import type { Commands, CoreCommands, CoreGitCommands, GlCommands } from '../../constants.commands'; +import { actionCommandPrefix, GlCommand } from '../../constants.commands'; import { Container } from '../../container'; import { isWebviewContext } from '../webview'; export type CommandCallback = Parameters[1]; -type CommandConstructor = new (container: Container, ...args: any[]) => Command; +type CommandConstructor = new (container: Container, ...args: any[]) => GlCommandBase; const registrableCommands: CommandConstructor[] = []; export function command(): ClassDecorator { @@ -19,12 +19,12 @@ export function command(): ClassDecorator { }; } -export function registerCommand(command: string, callback: CommandCallback, thisArg?: any): Disposable { +export function registerCommand(command: Commands, callback: CommandCallback, thisArg?: any): Disposable { return commands.registerCommand( command, function (this: any, ...args) { let context: any; - if (command === Commands.GitCommands) { + if (command === GlCommand.GitCommands) { const arg = args?.[0]; if (arg?.command != null) { context = { mode: args[0].command }; @@ -47,14 +47,14 @@ export function registerCommand(command: string, callback: CommandCallback, this 'context.submode': context?.submode, }); } - void Container.instance.usage.track(`command:${command as Commands}:executed`).catch(); + void Container.instance.usage.track(`command:${command}:executed`).catch(); callback.call(this, ...args); }, thisArg, ); } -export function registerWebviewCommand(command: string, callback: CommandCallback, thisArg?: any): Disposable { +export function registerWebviewCommand(command: Commands, callback: CommandCallback, thisArg?: any): Disposable { return commands.registerCommand( command, function (this: any, ...args) { @@ -87,14 +87,14 @@ export function registerCommands(container: Container): Disposable[] { } export function executeActionCommand(action: Action, args: Omit) { - return commands.executeCommand(`${Commands.ActionPrefix}${action}`, { ...args, type: action }); + return commands.executeCommand(`${actionCommandPrefix}${action}`, { ...args, type: action }); } export function createCommand( - command: Commands | CodeLensCommand | TreeViewCommands, + command: Commands | CodeLensCommand, title: string, ...args: T -): ICommand { +): Command { return { command: command, title: title, @@ -109,7 +109,7 @@ export function executeCommand(command: return commands.executeCommand(command, ...args); } -export function createCoreCommand(command: CoreCommands, title: string, ...args: T): ICommand { +export function createCoreCommand(command: CoreCommands, title: string, ...args: T): Command { return { command: command, title: title, @@ -142,7 +142,7 @@ export function createCoreGitCommand( command: CoreGitCommands, title: string, ...args: T -): ICommand { +): Command { return { command: command, title: title, @@ -164,6 +164,6 @@ export function executeCoreGitCommand( return commands.executeCommand(command, ...args); } -export function executeEditorCommand(command: Commands, uri: Uri | undefined, args: T) { +export function executeEditorCommand(command: GlCommands, uri: Uri | undefined, args: T) { return commands.executeCommand(command, uri, args); } diff --git a/src/telemetry/walkthroughStateProvider.ts b/src/telemetry/walkthroughStateProvider.ts index 2f5e44eddeeac..138c79de7559e 100644 --- a/src/telemetry/walkthroughStateProvider.ts +++ b/src/telemetry/walkthroughStateProvider.ts @@ -1,6 +1,6 @@ import type { Event } from 'vscode'; import { Disposable, EventEmitter } from 'vscode'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import { SubscriptionState } from '../constants.subscription'; import type { TrackedUsageKeys } from '../constants.telemetry'; import type { Container } from '../container'; @@ -31,8 +31,8 @@ const triedProStates: Readonly = [ ]; const tryProCommands: Readonly = [ - `command:${Commands.PlusStartPreviewTrial}:executed`, - `command:${Commands.PlusReactivateProTrial}:executed`, + `command:${GlCommand.PlusStartPreviewTrial}:executed`, + `command:${GlCommand.PlusReactivateProTrial}:executed`, ]; const walkthroughRequiredMapping: Readonly> = new Map< @@ -57,11 +57,11 @@ const walkthroughRequiredMapping: Readonly([ - [DeepLinkCommandType.CloudPatches, Commands.ShowDraftsView], - [DeepLinkCommandType.Graph, Commands.ShowGraph], - [DeepLinkCommandType.Inspect, Commands.ShowCommitDetailsView], - [DeepLinkCommandType.Launchpad, Commands.ShowLaunchpad], - [DeepLinkCommandType.Walkthrough, Commands.GetStarted], - [DeepLinkCommandType.Worktrees, Commands.ShowWorktreesView], + [DeepLinkCommandType.CloudPatches, GlCommand.ShowDraftsView], + [DeepLinkCommandType.Graph, GlCommand.ShowGraph], + [DeepLinkCommandType.Inspect, GlCommand.ShowCommitDetailsView], + [DeepLinkCommandType.Launchpad, GlCommand.ShowLaunchpad], + [DeepLinkCommandType.Walkthrough, GlCommand.GetStarted], + [DeepLinkCommandType.Worktrees, GlCommand.ShowWorktreesView], ]); export enum DeepLinkActionType { diff --git a/src/uris/deepLinks/deepLinkService.ts b/src/uris/deepLinks/deepLinkService.ts index e073d3d2316d7..5923b35cc4ff1 100644 --- a/src/uris/deepLinks/deepLinkService.ts +++ b/src/uris/deepLinks/deepLinkService.ts @@ -1,6 +1,6 @@ import type { QuickPickItem } from 'vscode'; import { Disposable, env, EventEmitter, ProgressLocation, Range, Uri, window, workspace } from 'vscode'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import type { StoredDeepLinkContext, StoredNamedRef } from '../../constants.storage'; import type { Container } from '../../container'; import { executeGitCommand } from '../../git/actions'; @@ -1123,7 +1123,7 @@ export class DeepLinkService implements Disposable { } if (targetType === DeepLinkType.Repository) { - void (await executeCommand(Commands.ShowInCommitGraph, repo)); + void (await executeCommand(GlCommand.ShowInCommitGraph, repo)); action = DeepLinkServiceAction.DeepLinkResolved; break; } @@ -1134,7 +1134,7 @@ export class DeepLinkService implements Disposable { break; } - void (await executeCommand(Commands.ShowInCommitGraph, { + void (await executeCommand(GlCommand.ShowInCommitGraph, { ref: createReference(targetSha, repo.path), })); @@ -1182,7 +1182,7 @@ export class DeepLinkService implements Disposable { prEntityId = fromBase64(prEntityId).toString(); } - void (await executeCommand(Commands.OpenCloudPatch, { + void (await executeCommand(GlCommand.OpenCloudPatch, { type: type === 'suggested_pr_change' ? 'code_suggestion' : 'patch', id: targetId, patchId: secondaryTargetId, diff --git a/src/views/branchesView.ts b/src/views/branchesView.ts index a6257f2f32c0e..24b078eae7646 100644 --- a/src/views/branchesView.ts +++ b/src/views/branchesView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vscode'; import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { BranchesViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; @@ -138,7 +138,7 @@ export class BranchesView extends ViewBase<'branches', BranchesViewNode, Branche return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/views/commitsView.ts b/src/views/commitsView.ts index fb41c20109c69..d2be2b60b4fc6 100644 --- a/src/views/commitsView.ts +++ b/src/views/commitsView.ts @@ -2,7 +2,7 @@ import type { CancellationToken, ConfigurationChangeEvent } from 'vscode'; import { Disposable, ProgressLocation, ThemeIcon, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { CommitsViewConfig, ViewFilesLayout } from '../config'; import { GlyphChars } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; @@ -162,7 +162,7 @@ export class CommitsViewNode extends RepositoriesSubscribeableNode executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/views/contributorsView.ts b/src/views/contributorsView.ts index 7fa965e2ae29e..2440998ab8af5 100644 --- a/src/views/contributorsView.ts +++ b/src/views/contributorsView.ts @@ -2,7 +2,7 @@ import type { CancellationToken, ConfigurationChangeEvent } from 'vscode'; import { Disposable, ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import { onDidFetchAvatar } from '../avatars'; import type { ContributorsViewConfig, ViewFilesLayout } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitContributor } from '../git/models/contributor'; @@ -156,7 +156,7 @@ export class ContributorsView extends ViewBase<'contributors', ContributorsViewN return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/views/draftsView.ts b/src/views/draftsView.ts index 680edd6ce1e5a..e740ad642a700 100644 --- a/src/views/draftsView.ts +++ b/src/views/draftsView.ts @@ -3,7 +3,7 @@ import { Disposable, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { OpenWalkthroughCommandArgs } from '../commands/walkthroughs'; import type { DraftsViewConfig } from '../config'; import { previewBadge } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { AuthenticationRequiredError } from '../errors'; import { unknownGitUri } from '../git/gitUri'; @@ -119,7 +119,7 @@ export class DraftsView extends ViewBase<'drafts', DraftsViewNode, DraftsViewCon registerViewCommand( this.getQualifiedCommand('info'), () => - executeCommand(Commands.OpenWalkthrough, { + executeCommand(GlCommand.OpenWalkthrough, { step: 'streamline-collaboration', source: 'cloud-patches', detail: 'info', @@ -128,14 +128,14 @@ export class DraftsView extends ViewBase<'drafts', DraftsViewNode, DraftsViewCon ), registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this), registerViewCommand( this.getQualifiedCommand('create'), async () => { - await executeCommand(Commands.CreateCloudPatch); + await executeCommand(GlCommand.CreateCloudPatch); void this.ensureRoot().triggerChange(true); }, this, diff --git a/src/views/fileHistoryView.ts b/src/views/fileHistoryView.ts index 5c8439960356c..396edd6a3029b 100644 --- a/src/views/fileHistoryView.ts +++ b/src/views/fileHistoryView.ts @@ -1,6 +1,6 @@ import type { ConfigurationChangeEvent, Disposable } from 'vscode'; import type { FileHistoryViewConfig } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import type { GitUri } from '../git/gitUri'; import { executeCommand } from '../system/vscode/command'; @@ -46,7 +46,7 @@ export class FileHistoryView extends ViewBase< return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this), diff --git a/src/views/launchpadView.ts b/src/views/launchpadView.ts index eb6049446cb2a..6ccfd6050ad58 100644 --- a/src/views/launchpadView.ts +++ b/src/views/launchpadView.ts @@ -3,7 +3,7 @@ import { Disposable, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, window import type { OpenWalkthroughCommandArgs } from '../commands/walkthroughs'; import type { LaunchpadViewConfig, ViewFilesLayout } from '../config'; import { proBadge } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { AuthenticationRequiredError } from '../errors'; import { PlusFeatures } from '../features'; @@ -97,7 +97,7 @@ export class LaunchpadItemNode extends CacheableChildrenViewNode<'launchpad-item }`; item.iconPath = lpi.author?.avatarUrl != null ? Uri.parse(lpi.author.avatarUrl) : undefined; item.command = createCommand<[Omit]>( - Commands.ShowLaunchpad, + GlCommand.ShowLaunchpad, 'Open in Launchpad', { source: 'launchpad-view', @@ -268,7 +268,7 @@ export class LaunchpadView extends ViewBase<'launchpad', LaunchpadViewNode, Laun registerViewCommand( this.getQualifiedCommand('info'), () => - executeCommand(Commands.OpenWalkthrough, { + executeCommand(GlCommand.OpenWalkthrough, { step: 'accelerate-pr-reviews', source: 'launchpad-view', detail: 'info', @@ -277,7 +277,7 @@ export class LaunchpadView extends ViewBase<'launchpad', LaunchpadViewNode, Laun ), registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/views/lineHistoryView.ts b/src/views/lineHistoryView.ts index 4998fe03f1c7a..c7152af343320 100644 --- a/src/views/lineHistoryView.ts +++ b/src/views/lineHistoryView.ts @@ -1,6 +1,6 @@ import type { ConfigurationChangeEvent, Disposable } from 'vscode'; import type { LineHistoryViewConfig } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { executeCommand } from '../system/vscode/command'; import { configuration } from '../system/vscode/configuration'; @@ -36,7 +36,7 @@ export class LineHistoryView extends ViewBase<'lineHistory', LineHistoryTrackerN return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this), diff --git a/src/views/nodes/UncommittedFileNode.ts b/src/views/nodes/UncommittedFileNode.ts index 7bf84f3a3b144..e1eed6906aff7 100644 --- a/src/views/nodes/UncommittedFileNode.ts +++ b/src/views/nodes/UncommittedFileNode.ts @@ -1,7 +1,7 @@ import type { Command } from 'vscode'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithPreviousCommandArgs } from '../../commands/diffWithPrevious'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import { StatusFileFormatter } from '../../git/formatters/statusFormatter'; import { GitUri } from '../../git/gitUri'; import type { GitFile } from '../../git/models/file'; @@ -110,7 +110,7 @@ export class UncommittedFileNode extends ViewFileNode<'uncommitted-file', ViewsW }; return { title: 'Open Changes with Previous Revision', - command: Commands.DiffWithPrevious, + command: GlCommand.DiffWithPrevious, arguments: [undefined, commandArgs], }; } diff --git a/src/views/nodes/commitFileNode.ts b/src/views/nodes/commitFileNode.ts index 54ff6e3b4fac4..a1c69f38660aa 100644 --- a/src/views/nodes/commitFileNode.ts +++ b/src/views/nodes/commitFileNode.ts @@ -2,7 +2,7 @@ import type { Command, Selection } from 'vscode'; import { TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; import type { DiffWithPreviousCommandArgs } from '../../commands/diffWithPrevious'; import { Schemes } from '../../constants'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import type { TreeViewRefFileNodeTypes } from '../../constants.views'; import { StatusFileFormatter } from '../../git/formatters/statusFormatter'; import { GitUri } from '../../git/gitUri'; @@ -175,7 +175,7 @@ export abstract class CommitFileNodeBase< }; return { title: 'Open Changes with Previous Revision', - command: Commands.DiffWithPrevious, + command: GlCommand.DiffWithPrevious, arguments: [undefined, commandArgs], }; } diff --git a/src/views/nodes/commitNode.ts b/src/views/nodes/commitNode.ts index 5bad2e66e0c8a..4ac6b0bfd86a7 100644 --- a/src/views/nodes/commitNode.ts +++ b/src/views/nodes/commitNode.ts @@ -2,7 +2,7 @@ import type { CancellationToken, Command } from 'vscode'; import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithPreviousCommandArgs } from '../../commands/diffWithPrevious'; import type { Colors } from '../../constants.colors'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import type { GitBranch } from '../../git/models/branch'; import type { GitCommit } from '../../git/models/commit'; @@ -208,7 +208,7 @@ export class CommitNode extends ViewRefNode<'commit', ViewsWithCommits | FileHis }; return { title: 'Open Changes with Previous Revision', - command: Commands.DiffWithPrevious, + command: GlCommand.DiffWithPrevious, arguments: [undefined, commandArgs], }; } diff --git a/src/views/nodes/fileRevisionAsCommitNode.ts b/src/views/nodes/fileRevisionAsCommitNode.ts index ebc600e0f6b62..1b17d09f9cc96 100644 --- a/src/views/nodes/fileRevisionAsCommitNode.ts +++ b/src/views/nodes/fileRevisionAsCommitNode.ts @@ -2,7 +2,7 @@ import type { CancellationToken, Command, Selection, Uri } from 'vscode'; import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithPreviousCommandArgs } from '../../commands/diffWithPrevious'; import type { Colors } from '../../constants.colors'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import type { Container } from '../../container'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { StatusFileFormatter } from '../../git/formatters/statusFormatter'; @@ -154,7 +154,7 @@ export class FileRevisionAsCommitNode extends ViewRefFileNode< if (this.commit.file?.hasConflicts) { return { title: 'Open Changes', - command: Commands.DiffWith, + command: GlCommand.DiffWith, arguments: [ { lhs: { @@ -187,7 +187,7 @@ export class FileRevisionAsCommitNode extends ViewRefFileNode< }; return { title: 'Open Changes with Previous Revision', - command: Commands.DiffWithPrevious, + command: GlCommand.DiffWithPrevious, arguments: [undefined, commandArgs], }; } diff --git a/src/views/nodes/mergeConflictCurrentChangesNode.ts b/src/views/nodes/mergeConflictCurrentChangesNode.ts index 476020467da1e..2f06c498df962 100644 --- a/src/views/nodes/mergeConflictCurrentChangesNode.ts +++ b/src/views/nodes/mergeConflictCurrentChangesNode.ts @@ -2,7 +2,7 @@ import type { CancellationToken, Command } from 'vscode'; import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithCommandArgs } from '../../commands/diffWith'; import { GlyphChars } from '../../constants'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import { GitUri } from '../../git/gitUri'; import type { GitCommit } from '../../git/models/commit'; import type { GitFile } from '../../git/models/file'; @@ -68,7 +68,7 @@ export class MergeConflictCurrentChangesNode extends ViewNode< ); } - return createCommand<[DiffWithCommandArgs]>(Commands.DiffWith, 'Open Changes', { + return createCommand<[DiffWithCommandArgs]>(GlCommand.DiffWith, 'Open Changes', { lhs: { sha: this.status.mergeBase, uri: GitUri.fromFile(this.file, this.status.repoPath, undefined, true), diff --git a/src/views/nodes/mergeConflictIncomingChangesNode.ts b/src/views/nodes/mergeConflictIncomingChangesNode.ts index 381c57005e182..5adfc9f264099 100644 --- a/src/views/nodes/mergeConflictIncomingChangesNode.ts +++ b/src/views/nodes/mergeConflictIncomingChangesNode.ts @@ -2,7 +2,7 @@ import type { CancellationToken, Command } from 'vscode'; import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithCommandArgs } from '../../commands/diffWith'; import { GlyphChars } from '../../constants'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import { GitUri } from '../../git/gitUri'; import type { GitCommit } from '../../git/models/commit'; import type { GitFile } from '../../git/models/file'; @@ -76,7 +76,7 @@ export class MergeConflictIncomingChangesNode extends ViewNode< ); } - return createCommand<[DiffWithCommandArgs]>(Commands.DiffWith, 'Open Changes', { + return createCommand<[DiffWithCommandArgs]>(GlCommand.DiffWith, 'Open Changes', { lhs: { sha: this.status.mergeBase, uri: GitUri.fromFile(this.file, this.status.repoPath, undefined, true), diff --git a/src/views/nodes/resultsFileNode.ts b/src/views/nodes/resultsFileNode.ts index e64418430d9f8..09d025ae2c9a4 100644 --- a/src/views/nodes/resultsFileNode.ts +++ b/src/views/nodes/resultsFileNode.ts @@ -1,7 +1,7 @@ import type { Command } from 'vscode'; import { TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithCommandArgs } from '../../commands/diffWith'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import { StatusFileFormatter } from '../../git/formatters/statusFormatter'; import { GitUri } from '../../git/gitUri'; import type { GitFile } from '../../git/models/file'; @@ -150,7 +150,7 @@ export class ResultsFileNode extends ViewRefFileNode<'results-file', View, State }; return { title: 'Open Changes', - command: Commands.DiffWith, + command: GlCommand.DiffWith, arguments: [commandArgs], }; } diff --git a/src/views/nodes/statusFileNode.ts b/src/views/nodes/statusFileNode.ts index 89cbda19c06f3..d4dad9510ac67 100644 --- a/src/views/nodes/statusFileNode.ts +++ b/src/views/nodes/statusFileNode.ts @@ -2,7 +2,7 @@ import type { Command } from 'vscode'; import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithCommandArgs } from '../../commands/diffWith'; import type { DiffWithPreviousCommandArgs } from '../../commands/diffWithPrevious'; -import { Commands } from '../../constants.commands'; +import { GlCommand } from '../../constants.commands'; import { StatusFileFormatter } from '../../git/formatters/statusFormatter'; import { GitUri } from '../../git/gitUri'; import type { GitFileWithCommit } from '../../git/models/file'; @@ -215,7 +215,7 @@ export class StatusFileNode extends ViewFileNode<'status-file', ViewsWithCommits }; return { title: 'Open Changes with Previous Revision', - command: Commands.DiffWithPrevious, + command: GlCommand.DiffWithPrevious, arguments: [undefined, commandArgs], }; } @@ -279,7 +279,7 @@ export class StatusFileNode extends ViewFileNode<'status-file', ViewsWithCommits return { title: 'Open Changes', - command: Commands.DiffWith, + command: GlCommand.DiffWith, arguments: [commandArgs], }; } diff --git a/src/views/pullRequestView.ts b/src/views/pullRequestView.ts index 0f2a8149aaac7..577966a90b4f2 100644 --- a/src/views/pullRequestView.ts +++ b/src/views/pullRequestView.ts @@ -1,7 +1,7 @@ import type { ConfigurationChangeEvent, Disposable } from 'vscode'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { PullRequestViewConfig, ViewFilesLayout } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { unknownGitUri } from '../git/gitUri'; import type { GitBranch } from '../git/models/branch'; @@ -95,7 +95,7 @@ export class PullRequestView extends ViewBase<'pullRequest', PullRequestViewNode return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this), diff --git a/src/views/remotesView.ts b/src/views/remotesView.ts index 1f6a9ae987062..3eb80f807f1ef 100644 --- a/src/views/remotesView.ts +++ b/src/views/remotesView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vscode'; import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { RemotesViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { getRemoteNameFromBranchName } from '../git/models/branch'; @@ -122,7 +122,7 @@ export class RemotesView extends ViewBase<'remotes', RemotesViewNode, RemotesVie return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/views/repositoriesView.ts b/src/views/repositoriesView.ts index da7b51425b8cb..4b47f78caf8e6 100644 --- a/src/views/repositoriesView.ts +++ b/src/views/repositoriesView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable, Event } from 'vscode'; import { EventEmitter, ProgressLocation, window } from 'vscode'; import type { RepositoriesViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { getRemoteNameFromBranchName } from '../git/models/branch'; import type { GitCommit } from '../git/models/commit'; @@ -59,7 +59,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode, return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/views/searchAndCompareView.ts b/src/views/searchAndCompareView.ts index 7a18afb919881..5547e5c0406f5 100644 --- a/src/views/searchAndCompareView.ts +++ b/src/views/searchAndCompareView.ts @@ -1,7 +1,7 @@ import type { ConfigurationChangeEvent, Disposable } from 'vscode'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { SearchAndCompareViewConfig, ViewFilesLayout } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { SearchQuery } from '../constants.search'; import type { StoredNamedRef, StoredSearchAndCompareItem } from '../constants.storage'; import type { Container } from '../container'; @@ -289,7 +289,7 @@ export class SearchAndCompareView extends ViewBase< registerViewCommand(this.getQualifiedCommand('clear'), () => void this.clear(), this), registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this), diff --git a/src/views/stashesView.ts b/src/views/stashesView.ts index 540862b3538f5..0ea9c5ecffbb0 100644 --- a/src/views/stashesView.ts +++ b/src/views/stashesView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vscode'; import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { StashesViewConfig, ViewFilesLayout } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitStashReference } from '../git/models/reference'; @@ -108,7 +108,7 @@ export class StashesView extends ViewBase<'stashes', StashesViewNode, StashesVie return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/views/tagsView.ts b/src/views/tagsView.ts index 0d2367100205b..be42f31649245 100644 --- a/src/views/tagsView.ts +++ b/src/views/tagsView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vscode'; import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { TagsViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../config'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitTagReference } from '../git/models/reference'; @@ -109,7 +109,7 @@ export class TagsView extends ViewBase<'tags', TagsViewNode, TagsViewConfig> { return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index 44111c845bff6..896056a02d2a0 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -9,7 +9,8 @@ import type { OpenFileAtRevisionCommandArgs } from '../commands/openFileAtRevisi import type { OpenOnRemoteCommandArgs } from '../commands/openOnRemote'; import type { ViewShowBranchComparison } from '../config'; import { GlyphChars } from '../constants'; -import { Commands } from '../constants.commands'; +import type { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { browseAtRevision, executeGitCommand } from '../git/actions'; import * as BranchActions from '../git/actions/branch'; @@ -98,7 +99,7 @@ interface CompareSelectedInfo { } export function registerViewCommand( - command: string, + command: Commands, callback: (...args: any[]) => unknown, thisArg?: any, multiselect: boolean | 'sequential' = false, @@ -144,12 +145,12 @@ export class ViewCommands implements Disposable { this._disposable = Disposable.from( registerViewCommand('gitlens.views.clearComparison', n => this.clearComparison(n), this), registerViewCommand('gitlens.views.clearReviewed', n => this.clearReviewed(n), this), - registerViewCommand(Commands.ViewsCopy, partial(copyNode, 'text'), this, true), - registerViewCommand(Commands.ViewsCopyAsMarkdown, partial(copyNode, 'markdown'), this, true), - registerViewCommand(Commands.ViewsCopyUrl, copyNodeUrl, this), - registerViewCommand(`${Commands.ViewsCopyUrl}.multi`, copyNodeUrl, this, true), - registerViewCommand(Commands.ViewsOpenUrl, openNodeUrl, this), - registerViewCommand(`${Commands.ViewsOpenUrl}.multi`, openNodeUrl, this, true), + registerViewCommand(GlCommand.ViewsCopy, partial(copyNode, 'text'), this, true), + registerViewCommand(GlCommand.ViewsCopyAsMarkdown, partial(copyNode, 'markdown'), this, true), + registerViewCommand(GlCommand.ViewsCopyUrl, copyNodeUrl, this), + registerViewCommand(`${GlCommand.ViewsCopyUrl}.multi`, copyNodeUrl, this, true), + registerViewCommand(GlCommand.ViewsOpenUrl, openNodeUrl, this), + registerViewCommand(`${GlCommand.ViewsOpenUrl}.multi`, openNodeUrl, this, true), registerViewCommand( 'gitlens.views.collapseNode', () => executeCoreCommand('list.collapseAllToFocus'), @@ -234,12 +235,12 @@ export class ViewCommands implements Disposable { registerViewCommand( 'gitlens.views.openBranchOnRemote', - n => executeCommand(Commands.OpenBranchOnRemote, n), + n => executeCommand(GlCommand.OpenBranchOnRemote, n), this, ), registerViewCommand( 'gitlens.views.openBranchOnRemote.multi', - n => executeCommand(Commands.OpenBranchOnRemote, n), + n => executeCommand(GlCommand.OpenBranchOnRemote, n), this, 'sequential', ), @@ -1241,7 +1242,7 @@ export class ViewCommands implements Disposable { rhsUri = await this.container.git.getWorkingUri(repoPath, lhsUri); } - return executeCommand(Commands.DiffWith, { + return executeCommand(GlCommand.DiffWith, { repoPath: repoPath, lhs: { sha: lhsRef, @@ -1326,7 +1327,7 @@ export class ViewCommands implements Disposable { private openCommitOnRemote(node: ViewRefNode, nodes?: ViewRefNode[], clipboard?: boolean) { const refs = nodes?.length ? nodes.map(n => n.ref) : [node.ref]; - return executeCommand(Commands.OpenOnRemote, { + return executeCommand(GlCommand.OpenOnRemote, { repoPath: refs[0].repoPath, resource: refs.map(r => ({ type: RemoteResourceType.Commit, sha: r.ref })), clipboard: clipboard, @@ -1336,7 +1337,7 @@ export class ViewCommands implements Disposable { @log() private openChanges(node: ViewRefFileNode | MergeConflictFileNode | StatusFileNode) { if (node.is('conflict-file')) { - void executeCommand(Commands.DiffWith, { + void executeCommand(GlCommand.DiffWith, { lhs: { sha: node.status.HEAD.ref, uri: GitUri.fromFile(node.file, node.repoPath, undefined, true), @@ -1362,13 +1363,13 @@ export class ViewCommands implements Disposable { if (command?.arguments == null) return; switch (command.command) { - case Commands.DiffWith: { + case GlCommand.DiffWith: { const [args] = command.arguments as [DiffWithCommandArgs]; args.showOptions!.preview = false; void executeCommand(command.command, args); break; } - case Commands.DiffWithPrevious: { + case GlCommand.DiffWithPrevious: { const [, args] = command.arguments as [Uri, DiffWithPreviousCommandArgs]; args.showOptions!.preview = false; void executeEditorCommand(command.command, undefined, args); @@ -1418,7 +1419,7 @@ export class ViewCommands implements Disposable { @log() private async openChangesWithWorking(node: ViewRefFileNode | MergeConflictFileNode | StatusFileNode) { if (node.is('status-file')) { - return executeEditorCommand(Commands.DiffWithWorking, undefined, { + return executeEditorCommand(GlCommand.DiffWithWorking, undefined, { uri: node.uri, showOptions: { preserveFocus: true, @@ -1428,7 +1429,7 @@ export class ViewCommands implements Disposable { } if (node.is('conflict-file')) { - return executeEditorCommand(Commands.DiffWithWorking, undefined, { + return executeEditorCommand(GlCommand.DiffWithWorking, undefined, { uri: node.baseUri, showOptions: { preserveFocus: true, @@ -1440,7 +1441,7 @@ export class ViewCommands implements Disposable { if (node.is('file-commit') && node.commit.file?.hasConflicts) { const baseUri = await node.getConflictBaseUri(); if (baseUri != null) { - return executeEditorCommand(Commands.DiffWithWorking, undefined, { + return executeEditorCommand(GlCommand.DiffWithWorking, undefined, { uri: baseUri, showOptions: { preserveFocus: true, diff --git a/src/views/views.ts b/src/views/views.ts index a2093fb779360..e9e60f1dc3957 100644 --- a/src/views/views.ts +++ b/src/views/views.ts @@ -1,6 +1,5 @@ import type { ConfigurationChangeEvent, MessageItem } from 'vscode'; import { Disposable, window } from 'vscode'; -import type { Commands } from '../constants.commands'; import type { GroupableTreeViewTypes, TreeViewTypes } from '../constants.views'; import type { Container } from '../container'; import type { GitContributor } from '../git/models/contributor'; @@ -12,11 +11,8 @@ import type { } from '../git/models/reference'; import type { GitRemote } from '../git/models/remote'; import type { GitWorktree } from '../git/models/worktree'; -import type { GraphWebviewShowingArgs } from '../plus/webviews/graph/registration'; import { registerGraphWebviewView } from '../plus/webviews/graph/registration'; -import type { PatchDetailsWebviewShowingArgs } from '../plus/webviews/patchDetails/registration'; import { registerPatchDetailsWebviewView } from '../plus/webviews/patchDetails/registration'; -import type { TimelineWebviewShowingArgs } from '../plus/webviews/timeline/registration'; import { registerTimelineWebviewView } from '../plus/webviews/timeline/registration'; import { once } from '../system/function'; import { first } from '../system/iterable'; @@ -24,14 +20,12 @@ import { compare } from '../system/version'; import { executeCommand, executeCoreCommand, registerCommand } from '../system/vscode/command'; import { configuration } from '../system/vscode/configuration'; import { getContext, setContext } from '../system/vscode/context'; -import type { CommitDetailsWebviewShowingArgs } from '../webviews/commitDetails/registration'; import { registerCommitDetailsWebviewView, registerGraphDetailsWebviewView, } from '../webviews/commitDetails/registration'; -import type { HomeWebviewShowingArgs } from '../webviews/home/registration'; import { registerHomeWebviewView } from '../webviews/home/registration'; -import type { WebviewsController, WebviewViewProxy } from '../webviews/webviewsController'; +import type { WebviewsController } from '../webviews/webviewsController'; import { BranchesView } from './branchesView'; import { CommitsView } from './commitsView'; import { ContributorsView } from './contributorsView'; @@ -285,7 +279,7 @@ export class Views implements Disposable { registerCommand('gitlens.views.scm.grouped.refresh', () => { if (this._scmGroupedView?.view == null) return; - executeCommand(`gitlens.views.${this._scmGroupedView.view.type}.refresh` as Commands); + executeCommand(`gitlens.views.${this._scmGroupedView.view.type}.refresh`); }), registerCommand('gitlens.views.scm.grouped.detachAll', () => updateScmGroupedViewsInConfig(new Set())), registerCommand('gitlens.views.scm.grouped.regroupAll', () => @@ -442,9 +436,9 @@ export class Views implements Disposable { ); if (result === Restore) { - executeCommand('gitlens.views.scm.grouped.welcome.restore' as Commands); + executeCommand('gitlens.views.scm.grouped.welcome.restore'); } else { - executeCommand('gitlens.views.scm.grouped.welcome.dismiss' as Commands); + executeCommand('gitlens.views.scm.grouped.welcome.dismiss'); } } @@ -569,7 +563,7 @@ export class Views implements Disposable { return this._commitsView ?? this.getScmGroupedView('commits'); } - private _commitDetailsView!: WebviewViewProxy; + private _commitDetailsView!: ReturnType; get commitDetails() { return this._commitDetailsView; } @@ -589,17 +583,17 @@ export class Views implements Disposable { return this._fileHistoryView; } - private _graphView!: WebviewViewProxy; + private _graphView!: ReturnType; get graph() { return this._graphView; } - private _graphDetailsView!: WebviewViewProxy; + private _graphDetailsView!: ReturnType; get graphDetails() { return this._graphDetailsView; } - private _homeView!: WebviewViewProxy; + private _homeView!: ReturnType; get home() { return this._homeView; } @@ -614,7 +608,7 @@ export class Views implements Disposable { // return this._lineHistoryView; // } - private _patchDetailsView!: WebviewViewProxy; + private _patchDetailsView!: ReturnType; get patchDetails() { return this._patchDetailsView; } @@ -649,7 +643,7 @@ export class Views implements Disposable { return this._tagsView ?? this.getScmGroupedView('tags'); } - private _timelineView!: WebviewViewProxy; + private _timelineView!: ReturnType; get timeline() { return this._timelineView; } diff --git a/src/views/workspacesView.ts b/src/views/workspacesView.ts index d0dbedb5df173..b34b16247fc3f 100644 --- a/src/views/workspacesView.ts +++ b/src/views/workspacesView.ts @@ -2,7 +2,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vs import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { WorkspacesViewConfig } from '../config'; import { previewBadge, urls } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { unknownGitUri } from '../git/gitUri'; import type { Repository } from '../git/models/repository'; @@ -148,7 +148,7 @@ export class WorkspacesView extends ViewBase<'workspaces', WorkspacesViewNode, W registerViewCommand(this.getQualifiedCommand('info'), () => openUrl(urls.workspaces), this), registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/views/worktreesView.ts b/src/views/worktreesView.ts index a42b82b976e77..f61a6a376c00d 100644 --- a/src/views/worktreesView.ts +++ b/src/views/worktreesView.ts @@ -2,7 +2,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vs import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { ViewFilesLayout, WorktreesViewConfig } from '../config'; import { proBadge } from '../constants'; -import { Commands } from '../constants.commands'; +import { GlCommand } from '../constants.commands'; import type { Container } from '../container'; import { PlusFeatures } from '../features'; import { GitUri } from '../git/gitUri'; @@ -137,7 +137,7 @@ export class WorktreesView extends ViewBase<'worktrees', WorktreesViewNode, Work return [ registerViewCommand( this.getQualifiedCommand('copy'), - () => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection), + () => executeCommand(GlCommand.ViewsCopy, this.activeSelection, this.selection), this, ), registerViewCommand( diff --git a/src/webviews/apps/commitDetails/components/commit-details-app.ts b/src/webviews/apps/commitDetails/components/commit-details-app.ts index 5d3449fd9a504..c380f6caf8f8d 100644 --- a/src/webviews/apps/commitDetails/components/commit-details-app.ts +++ b/src/webviews/apps/commitDetails/components/commit-details-app.ts @@ -3,6 +3,7 @@ import { html, LitElement, nothing } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; import { when } from 'lit/directives/when.js'; import type { ViewFilesLayout } from '../../../../config'; +import type { Commands } from '../../../../constants.commands'; import { pluralize } from '../../../../system/string'; import type { Serialized } from '../../../../system/vscode/serialize'; import type { DraftState, ExecuteCommitActionsParams, Mode, State } from '../../../commitDetails/protocol'; @@ -583,8 +584,8 @@ export class GlCommitDetailsApp extends LitElement { this._hostIpc.sendCommand(CreatePatchFromWipCommand, { changes: this.state.wip.changes, checked: checked }); } - private onCommandClickedCore(action?: string) { - const command = action?.startsWith('command:') ? action.slice(8) : action; + private onCommandClickedCore(action?: Commands | `command:${Commands}`) { + const command = (action?.startsWith('command:') ? action.slice(8) : action) as Commands | undefined; if (command == null) return; this._hostIpc.sendCommand(ExecuteCommand, { command: command }); diff --git a/src/webviews/apps/home/components/onboarding.ts b/src/webviews/apps/home/components/onboarding.ts index 945fe7d2505be..11360fcd969f3 100644 --- a/src/webviews/apps/home/components/onboarding.ts +++ b/src/webviews/apps/home/components/onboarding.ts @@ -1,7 +1,7 @@ import { consume } from '@lit/context'; import { html, LitElement } from 'lit'; import { customElement, query, state } from 'lit/decorators.js'; -import { Commands } from '../../../../constants.commands'; +import { GlCommand } from '../../../../constants.commands'; import { createCommandLink } from '../../../../system/commands'; import type { State } from '../../../home/protocol'; import { DismissWalkthroughSection } from '../../../home/protocol'; @@ -43,7 +43,7 @@ export class GlOnboarding extends LitElement {