diff --git a/extensions/git/package.json b/extensions/git/package.json index 8ff55b2a41576..fdfd6e77c2aa7 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -491,6 +491,11 @@ "category": "Git", "enablement": "!operationInProgress" }, + { + "command": "git.graph.copyBranchName", + "title": "%command.artifactCopyBranchName%", + "category": "Git" + }, { "command": "git.checkoutDetached", "title": "%command.checkoutDetached%", @@ -2749,6 +2754,11 @@ "command": "git.graph.deleteTag", "when": "scmProvider == git && scmHistoryItemRef =~ /^refs\\/tags\\//", "group": "3_tag@2" + }, + { + "command": "git.graph.copyBranchName", + "when": "scmProvider == git && scmHistoryItemRef =~ /^refs\\/heads\\/|^refs\\/remotes\\//", + "group": "9_copy@1" } ], "editor/title": [ @@ -3129,6 +3139,10 @@ { "command": "git.publish", "group": "4_publish@1" + }, + { + "command": "git.graph.copyBranchName", + "group": "5_copy@1" } ], "git.remotes": [ diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 51cbef08d2e68..0fede5e6a4fad 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -3179,6 +3179,16 @@ export class CommandCenter { await this._deleteBranch(repository, remoteName, refName, { remote: true }); } + @command('git.graph.copyBranchName', { repository: true }) + async graphCopyBranchName(_repository: Repository, historyItem?: SourceControlHistoryItem, historyItemRefId?: string): Promise { + const historyItemRef = historyItem?.references?.find(r => r.id === historyItemRefId); + if (!historyItemRef?.name) { + return; + } + + env.clipboard.writeText(historyItemRef.name); + } + @command('git.graph.compareWithRemote', { repository: true }) async compareWithRemote(repository: Repository, historyItem?: SourceControlHistoryItem): Promise { if (!historyItem || !repository.historyProvider.currentHistoryItemRemoteRef) {