From fc4e78cbfe5c7e5e365ebe9fd43b7cf157d229c3 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Mon, 6 Jan 2025 22:17:09 +0100 Subject: [PATCH] Git - remove commands that are not used (#237368) Git - remove commands that are not used --- extensions/git/package.json | 11 ----- extensions/git/package.nls.json | 1 - extensions/git/src/blame.ts | 4 +- extensions/git/src/commands.ts | 61 +------------------------- extensions/git/src/timelineProvider.ts | 2 +- 5 files changed, 5 insertions(+), 74 deletions(-) diff --git a/extensions/git/package.json b/extensions/git/package.json index 064dfe3f1cf..66e8dd4981d 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -912,13 +912,6 @@ "category": "Git", "enablement": "!operationInProgress" }, - { - "command": "git.viewAllChanges", - "title": "%command.viewAllChanges%", - "icon": "$(diff-multiple)", - "category": "Git", - "enablement": "!operationInProgress" - }, { "command": "git.copyCommitId", "title": "%command.timelineCopyCommitId%", @@ -1444,10 +1437,6 @@ "command": "git.viewCommit", "when": "false" }, - { - "command": "git.viewAllChanges", - "when": "false" - }, { "command": "git.stageFile", "when": "false" diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index afbb44ba48f..e7020f41890 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -125,7 +125,6 @@ "command.viewChanges": "View Changes", "command.viewStagedChanges": "View Staged Changes", "command.viewUntrackedChanges": "View Untracked Changes", - "command.viewAllChanges": "View All Changes", "command.viewCommit": "View Commit", "command.api.getRepositories": "Get Repositories", "command.api.getRepositoryState": "Get Repository State", diff --git a/extensions/git/src/blame.ts b/extensions/git/src/blame.ts index c4ca348eef9..c8f15ffdf94 100644 --- a/extensions/git/src/blame.ts +++ b/extensions/git/src/blame.ts @@ -265,7 +265,7 @@ export class GitBlameController { markdownString.appendMarkdown(`\n\n---\n\n`); } - markdownString.appendMarkdown(`[\`$(git-commit) ${getCommitShortHash(documentUri, blameInformationOrCommit.hash)} \`](command:git.viewCommit2?${encodeURIComponent(JSON.stringify([documentUri, blameInformationOrCommit.hash]))} "${l10n.t('View Commit')}")`); + markdownString.appendMarkdown(`[\`$(git-commit) ${getCommitShortHash(documentUri, blameInformationOrCommit.hash)} \`](command:git.viewCommit?${encodeURIComponent(JSON.stringify([documentUri, blameInformationOrCommit.hash]))} "${l10n.t('View Commit')}")`); markdownString.appendMarkdown(' '); markdownString.appendMarkdown(`[$(copy)](command:git.copyContentToClipboard?${encodeURIComponent(JSON.stringify(blameInformationOrCommit.hash))} "${l10n.t('Copy Commit Hash')}")`); markdownString.appendMarkdown('  |  '); @@ -702,7 +702,7 @@ class GitBlameStatusBarItem { this._statusBarItem.tooltip = this._controller.getBlameInformationHover(window.activeTextEditor.document.uri, blameInformation[0].blameInformation); this._statusBarItem.command = { title: l10n.t('View Commit'), - command: 'git.viewCommit2', + command: 'git.viewCommit', arguments: [window.activeTextEditor.document.uri, blameInformation[0].blameInformation.hash] } satisfies Command; } diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index ab344ad5023..b8fa9009e1f 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -4271,63 +4271,6 @@ export class CommandCenter { }); } - @command('git.viewCommit', { repository: true }) - async viewCommit(repository: Repository, historyItem1: SourceControlHistoryItem, historyItem2?: SourceControlHistoryItem): Promise { - if (!repository || !historyItem1) { - return; - } - - if (historyItem2) { - const mergeBase = await repository.getMergeBase(historyItem1.id, historyItem2.id); - if (!mergeBase || (mergeBase !== historyItem1.id && mergeBase !== historyItem2.id)) { - return; - } - } - - let title: string | undefined; - let historyItemParentId: string | undefined; - const rootUri = Uri.file(repository.root); - - // If historyItem2 is not provided, we are viewing a single commit. If historyItem2 is - // provided, we are viewing a range and we have to include both start and end commits. - // TODO@lszomoru - handle the case when historyItem2 is the first commit in the repository - if (!historyItem2) { - const commit = await repository.getCommit(historyItem1.id); - title = `${getCommitShortHash(rootUri, historyItem1.id)} - ${truncate(commit.message)}`; - historyItemParentId = historyItem1.parentIds.length > 0 ? historyItem1.parentIds[0] : `${historyItem1.id}^`; - } else { - title = l10n.t('All Changes ({0} ↔ {1})', getCommitShortHash(rootUri, historyItem2.id), getCommitShortHash(rootUri, historyItem1.id)); - historyItemParentId = historyItem2.parentIds.length > 0 ? historyItem2.parentIds[0] : `${historyItem2.id}^`; - } - - const multiDiffSourceUri = Uri.from({ scheme: 'scm-history-item', path: `${repository.root}/${historyItemParentId}..${historyItem1.id}` }); - - await this._viewChanges(repository, historyItem1.id, historyItemParentId, multiDiffSourceUri, title); - } - - @command('git.viewAllChanges', { repository: true }) - async viewAllChanges(repository: Repository, historyItem: SourceControlHistoryItem): Promise { - if (!repository || !historyItem) { - return; - } - - const rootUri = Uri.file(repository.root); - const modifiedShortRef = getCommitShortHash(rootUri, historyItem.id); - const originalShortRef = historyItem.parentIds.length > 0 ? getCommitShortHash(rootUri, historyItem.parentIds[0]) : `${modifiedShortRef}^`; - const title = l10n.t('All Changes ({0} ↔ {1})', originalShortRef, modifiedShortRef); - - const multiDiffSourceUri = toGitUri(Uri.file(repository.root), historyItem.id, { scheme: 'git-changes' }); - - await this._viewChanges(repository, modifiedShortRef, originalShortRef, multiDiffSourceUri, title); - } - - async _viewChanges(repository: Repository, historyItemId: string, historyItemParentId: string, multiDiffSourceUri: Uri, title: string): Promise { - const changes = await repository.diffBetween(historyItemParentId, historyItemId); - const resources = changes.map(c => toMultiFileDiffEditorUris(c, historyItemParentId, historyItemId)); - - await commands.executeCommand('_workbench.openMultiDiffEditor', { multiDiffSourceUri, title, resources }); - } - @command('git.copyCommitId', { repository: true }) async copyCommitId(repository: Repository, historyItem: SourceControlHistoryItem): Promise { if (!repository || !historyItem) { @@ -4346,8 +4289,8 @@ export class CommandCenter { env.clipboard.writeText(historyItem.message); } - @command('git.viewCommit2', { repository: true }) - async viewCommit2(repository: Repository, historyItemId: string): Promise { + @command('git.viewCommit', { repository: true }) + async viewCommit(repository: Repository, historyItemId: string): Promise { if (!repository || !historyItemId) { return; } diff --git a/extensions/git/src/timelineProvider.ts b/extensions/git/src/timelineProvider.ts index 4f5c53f9e50..2b3da08f82e 100644 --- a/extensions/git/src/timelineProvider.ts +++ b/extensions/git/src/timelineProvider.ts @@ -86,7 +86,7 @@ export class GitTimelineItem extends TimelineItem { if (hash) { this.tooltip.appendMarkdown(`---\n\n`); - this.tooltip.appendMarkdown(`[\`$(git-commit) ${getCommitShortHash(uri, hash)} \`](command:git.viewCommit2?${encodeURIComponent(JSON.stringify([uri, hash]))} "${l10n.t('View Commit')}")`); + this.tooltip.appendMarkdown(`[\`$(git-commit) ${getCommitShortHash(uri, hash)} \`](command:git.viewCommit?${encodeURIComponent(JSON.stringify([uri, hash]))} "${l10n.t('View Commit')}")`); this.tooltip.appendMarkdown(' '); this.tooltip.appendMarkdown(`[$(copy)](command:git.copyContentToClipboard?${encodeURIComponent(JSON.stringify(hash))} "${l10n.t('Copy Commit Hash')}")`); }