Git - add more commands to repositories view (#274484)

* Git - add actions to delete branch/tag

* Fix rebase action label

* Git - add more commands
This commit is contained in:
Ladislau Szomoru
2025-11-01 12:27:56 +00:00
committed by GitHub
parent c0755c9484
commit 69e17b67f1
3 changed files with 90 additions and 2 deletions

View File

@@ -1071,6 +1071,24 @@
"title": "%command.rebase2%", "title": "%command.rebase2%",
"category": "Git", "category": "Git",
"enablement": "!operationInProgress" "enablement": "!operationInProgress"
},
{
"command": "git.repositories.deleteBranch",
"title": "%command.deleteRef%",
"category": "Git",
"enablement": "!operationInProgress"
},
{
"command": "git.repositories.deleteTag",
"title": "%command.deleteRef%",
"category": "Git",
"enablement": "!operationInProgress"
},
{
"command": "git.repositories.createFrom",
"title": "%command.createFrom%",
"category": "Git",
"enablement": "!operationInProgress"
} }
], ],
"continueEditSession": [ "continueEditSession": [
@@ -1722,6 +1740,18 @@
{ {
"command": "git.repositories.rebase", "command": "git.repositories.rebase",
"when": "false" "when": "false"
},
{
"command": "git.repositories.deleteBranch",
"when": "false"
},
{
"command": "git.repositories.deleteTag",
"when": "false"
},
{
"command": "git.repositories.createFrom",
"when": "false"
} }
], ],
"scm/title": [ "scm/title": [
@@ -1950,9 +1980,24 @@
"group": "2_modify@2", "group": "2_modify@2",
"when": "scmProvider == git && scmArtifactGroupId == branches" "when": "scmProvider == git && scmArtifactGroupId == branches"
}, },
{
"command": "git.repositories.createFrom",
"group": "3_modify@1",
"when": "scmProvider == git && scmArtifactGroupId == branches"
},
{
"command": "git.repositories.deleteBranch",
"group": "3_modify@2",
"when": "scmProvider == git && scmArtifactGroupId == branches"
},
{
"command": "git.repositories.deleteTag",
"group": "3_modify@1",
"when": "scmProvider == git && scmArtifactGroupId == tags"
},
{ {
"command": "git.repositories.compareRef", "command": "git.repositories.compareRef",
"group": "3_compare@1", "group": "4_compare@1",
"when": "scmProvider == git" "when": "scmProvider == git"
} }
], ],

View File

@@ -77,7 +77,8 @@
"command.merge2": "Merge", "command.merge2": "Merge",
"command.mergeAbort": "Abort Merge", "command.mergeAbort": "Abort Merge",
"command.rebase": "Rebase Branch...", "command.rebase": "Rebase Branch...",
"command.rebase2": "Rebase Branch", "command.rebase2": "Rebase",
"command.createFrom": "Create from...",
"command.createTag": "Create Tag...", "command.createTag": "Create Tag...",
"command.deleteTag": "Delete Tag...", "command.deleteTag": "Delete Tag...",
"command.migrateWorktreeChanges": "Migrate Worktree Changes...", "command.migrateWorktreeChanges": "Migrate Worktree Changes...",
@@ -142,6 +143,7 @@
"command.graphCompareRef": "Compare with...", "command.graphCompareRef": "Compare with...",
"command.graphCompareWithMergeBase": "Compare with Merge Base", "command.graphCompareWithMergeBase": "Compare with Merge Base",
"command.graphCompareWithRemote": "Compare with Remote", "command.graphCompareWithRemote": "Compare with Remote",
"command.deleteRef": "Delete",
"command.blameToggleEditorDecoration": "Toggle Git Blame Editor Decoration", "command.blameToggleEditorDecoration": "Toggle Git Blame Editor Decoration",
"command.blameToggleStatusBarItem": "Toggle Git Blame Status Bar Item", "command.blameToggleStatusBarItem": "Toggle Git Blame Status Bar Item",
"command.api.getRepositories": "Get Repositories", "command.api.getRepositories": "Get Repositories",

View File

@@ -5296,6 +5296,15 @@ export class CommandCenter {
await repository.rebase(artifact.id); await repository.rebase(artifact.id);
} }
@command('git.repositories.createFrom', { repository: true })
async artifactCreateFrom(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
if (!repository || !artifact) {
return;
}
await this._branch(repository, undefined, false, artifact.id);
}
@command('git.repositories.compareRef', { repository: true }) @command('git.repositories.compareRef', { repository: true })
async artifactCompareWith(repository: Repository, artifact: SourceControlArtifact): Promise<void> { async artifactCompareWith(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
if (!repository || !artifact) { if (!repository || !artifact) {
@@ -5352,6 +5361,38 @@ export class CommandCenter {
await repository.tag({ name, message: inputMessage, ref }); await repository.tag({ name, message: inputMessage, ref });
} }
@command('git.repositories.deleteBranch', { repository: true })
async artifactDeleteBranch(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
if (!repository || !artifact) {
return;
}
const message = l10n.t('Are you sure you want to DELETE branch "{0}"? This action will permanently remove the branch reference from the repository.', artifact.name);
const yes = l10n.t('Yes');
const result = await window.showWarningMessage(message, { modal: true }, yes);
if (result !== yes) {
return;
}
await this._deleteBranch(repository, undefined, artifact.name, { remote: false });
}
@command('git.repositories.deleteTag', { repository: true })
async artifactDeleteTag(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
if (!repository || !artifact) {
return;
}
const message = l10n.t('Are you sure you want to DELETE tag "{0}"? This action will permanently remove the tag reference from the repository.', artifact.name);
const yes = l10n.t('Yes');
const result = await window.showWarningMessage(message, { modal: true }, yes);
if (result !== yes) {
return;
}
await repository.deleteTag(artifact.name);
}
private createCommand(id: string, key: string, method: Function, options: ScmCommandOptions): (...args: any[]) => any { private createCommand(id: string, key: string, method: Function, options: ScmCommandOptions): (...args: any[]) => any {
const result = (...args: any[]) => { const result = (...args: any[]) => {
let result: Promise<any>; let result: Promise<any>;