Git - remove commands that are not used (#237368)
Git - remove commands that are not usedpull/152187/merge
parent
28cb527948
commit
fc4e78cbfe
|
@ -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"
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -4271,63 +4271,6 @@ export class CommandCenter {
|
|||
});
|
||||
}
|
||||
|
||||
@command('git.viewCommit', { repository: true })
|
||||
async viewCommit(repository: Repository, historyItem1: SourceControlHistoryItem, historyItem2?: SourceControlHistoryItem): Promise<void> {
|
||||
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<void> {
|
||||
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<void> {
|
||||
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<void> {
|
||||
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<void> {
|
||||
@command('git.viewCommit', { repository: true })
|
||||
async viewCommit(repository: Repository, historyItemId: string): Promise<void> {
|
||||
if (!repository || !historyItemId) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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')}")`);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue