mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-02 00:09:30 +01:00
Git - add commands to copy information in the repositories view (#298558)
This commit is contained in:
@@ -1147,6 +1147,46 @@
|
||||
"title": "%command.deleteRef%",
|
||||
"category": "Git",
|
||||
"enablement": "!operationInProgress"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.worktreeCopyBranchName",
|
||||
"title": "%command.artifactCopyBranchName%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.worktreeCopyCommitHash",
|
||||
"title": "%command.artifactCopyCommitHash%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.worktreeCopyPath",
|
||||
"title": "%command.artifactCopyWorktreePath%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyCommitHash",
|
||||
"title": "%command.artifactCopyCommitHash%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyBranchName",
|
||||
"title": "%command.artifactCopyBranchName%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyTagName",
|
||||
"title": "%command.artifactCopyTagName%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyStashName",
|
||||
"title": "%command.artifactCopyStashName%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.stashCopyBranchName",
|
||||
"title": "%command.artifactCopyBranchName%",
|
||||
"category": "Git"
|
||||
}
|
||||
],
|
||||
"continueEditSession": [
|
||||
@@ -1846,6 +1886,38 @@
|
||||
{
|
||||
"command": "git.repositories.deleteWorktree",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.worktreeCopyBranchName",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.worktreeCopyCommitHash",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.worktreeCopyPath",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyCommitHash",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyBranchName",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyTagName",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyStashName",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.stashCopyBranchName",
|
||||
"when": "false"
|
||||
}
|
||||
],
|
||||
"scm/title": [
|
||||
@@ -2090,6 +2162,16 @@
|
||||
"group": "3_drop@3",
|
||||
"when": "scmProvider == git && scmArtifactGroupId == stashes"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.stashCopyBranchName",
|
||||
"group": "4_copy@1",
|
||||
"when": "scmProvider == git && scmArtifactGroupId == stashes"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyStashName",
|
||||
"group": "4_copy@2",
|
||||
"when": "scmProvider == git && scmArtifactGroupId == stashes"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.checkout",
|
||||
"group": "1_checkout@1",
|
||||
@@ -2130,6 +2212,21 @@
|
||||
"group": "4_compare@1",
|
||||
"when": "scmProvider == git && (scmArtifactGroupId == branches || scmArtifactGroupId == tags)"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyCommitHash",
|
||||
"group": "5_copy@2",
|
||||
"when": "scmProvider == git && (scmArtifactGroupId == branches || scmArtifactGroupId == tags)"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyBranchName",
|
||||
"group": "5_copy@1",
|
||||
"when": "scmProvider == git && scmArtifactGroupId == branches"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.copyTagName",
|
||||
"group": "5_copy@2",
|
||||
"when": "scmProvider == git && scmArtifactGroupId == tags"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.openWorktreeInNewWindow",
|
||||
"group": "inline@1",
|
||||
@@ -2149,6 +2246,21 @@
|
||||
"command": "git.repositories.deleteWorktree",
|
||||
"group": "2_modify@1",
|
||||
"when": "scmProvider == git && scmArtifactGroupId == worktrees"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.worktreeCopyCommitHash",
|
||||
"group": "3_copy@2",
|
||||
"when": "scmProvider == git && scmArtifactGroupId == worktrees"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.worktreeCopyBranchName",
|
||||
"group": "3_copy@1",
|
||||
"when": "scmProvider == git && scmArtifactGroupId == worktrees"
|
||||
},
|
||||
{
|
||||
"command": "git.repositories.worktreeCopyPath",
|
||||
"group": "3_copy@3",
|
||||
"when": "scmProvider == git && scmArtifactGroupId == worktrees"
|
||||
}
|
||||
],
|
||||
"scm/resourceGroup/context": [
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
"command.stashView": "View Stash...",
|
||||
"command.stashView2": "View Stash",
|
||||
"command.timelineOpenDiff": "Open Changes",
|
||||
"command.timelineCopyCommitId": "Copy Commit ID",
|
||||
"command.timelineCopyCommitId": "Copy Commit Hash",
|
||||
"command.timelineCopyCommitMessage": "Copy Commit Message",
|
||||
"command.timelineSelectForCompare": "Select for Compare",
|
||||
"command.timelineCompareWithSelected": "Compare with Selected",
|
||||
@@ -148,6 +148,11 @@
|
||||
"command.graphCompareWithMergeBase": "Compare with Merge Base",
|
||||
"command.graphCompareWithRemote": "Compare with Remote",
|
||||
"command.deleteRef": "Delete",
|
||||
"command.artifactCopyCommitHash": "Copy Commit Hash",
|
||||
"command.artifactCopyBranchName": "Copy Branch Name",
|
||||
"command.artifactCopyTagName": "Copy Tag Name",
|
||||
"command.artifactCopyStashName": "Copy Stash Name",
|
||||
"command.artifactCopyWorktreePath": "Copy Worktree Path",
|
||||
"command.blameToggleEditorDecoration": "Toggle Git Blame Editor Decoration",
|
||||
"command.blameToggleStatusBarItem": "Toggle Git Blame Status Bar Item",
|
||||
"command.api.getRepositories": "Get Repositories",
|
||||
|
||||
@@ -5415,6 +5415,97 @@ export class CommandCenter {
|
||||
await repository.deleteWorktree(artifact.id);
|
||||
}
|
||||
|
||||
@command('git.repositories.worktreeCopyBranchName', { repository: true })
|
||||
async artifactWorktreeCopyBranchName(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
const worktrees = await repository.getWorktreeDetails();
|
||||
const worktree = worktrees.find(w => w.path === artifact.id);
|
||||
if (!worktree || worktree.detached) {
|
||||
return;
|
||||
}
|
||||
|
||||
env.clipboard.writeText(worktree.ref.substring(11));
|
||||
}
|
||||
|
||||
@command('git.repositories.worktreeCopyCommitHash', { repository: true })
|
||||
async artifactWorktreeCopyCommitHash(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
const worktrees = await repository.getWorktreeDetails();
|
||||
const worktree = worktrees.find(w => w.path === artifact.id);
|
||||
if (!worktree?.commitDetails) {
|
||||
return;
|
||||
}
|
||||
|
||||
env.clipboard.writeText(worktree.commitDetails.hash);
|
||||
}
|
||||
|
||||
@command('git.repositories.worktreeCopyPath', { repository: true })
|
||||
async artifactWorktreeCopyPath(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
env.clipboard.writeText(artifact.id);
|
||||
}
|
||||
|
||||
@command('git.repositories.copyCommitHash', { repository: true })
|
||||
async artifactCopyCommitHash(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
const commit = await repository.getCommit(artifact.id);
|
||||
env.clipboard.writeText(commit.hash);
|
||||
}
|
||||
|
||||
@command('git.repositories.copyBranchName', { repository: true })
|
||||
async artifactCopyBranchName(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
env.clipboard.writeText(artifact.name);
|
||||
}
|
||||
|
||||
@command('git.repositories.copyTagName', { repository: true })
|
||||
async artifactCopyTagName(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
env.clipboard.writeText(artifact.name);
|
||||
}
|
||||
|
||||
@command('git.repositories.copyStashName', { repository: true })
|
||||
async artifactCopyStashName(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact) {
|
||||
return;
|
||||
}
|
||||
|
||||
env.clipboard.writeText(artifact.name);
|
||||
}
|
||||
|
||||
@command('git.repositories.stashCopyBranchName', { repository: true })
|
||||
async artifactStashCopyBranchName(repository: Repository, artifact: SourceControlArtifact): Promise<void> {
|
||||
if (!repository || !artifact?.description) {
|
||||
return;
|
||||
}
|
||||
|
||||
const stashes = await repository.getStashes();
|
||||
const stash = stashes.find(s => artifact.id === `stash@{${s.index}}`);
|
||||
if (!stash?.branchName) {
|
||||
return;
|
||||
}
|
||||
|
||||
env.clipboard.writeText(stash.branchName);
|
||||
}
|
||||
|
||||
private createCommand(id: string, key: string, method: Function, options: ScmCommandOptions): (...args: any[]) => any {
|
||||
const result = (...args: any[]) => {
|
||||
let result: Promise<any>;
|
||||
|
||||
Reference in New Issue
Block a user