From 445edcc0932c06613ea520af7f8c52a628df483e Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 7 Feb 2022 02:00:11 -0500 Subject: [PATCH] Hides commands not available in virtual workspaces --- package.json | 370 ++++++++++++++++---------------- src/commands/git/stash.ts | 12 +- src/commands/gitCommands.utils.ts | 55 +++-- src/constants.ts | 2 + src/context.ts | 12 +- src/extension.ts | 4 +- src/git/gitProviderService.ts | 6 +- src/premium/github/githubGitProvider.ts | 31 ++- 8 files changed, 279 insertions(+), 213 deletions(-) diff --git a/package.json b/package.json index 4995dc3..c6d0545 100644 --- a/package.json +++ b/package.json @@ -5662,7 +5662,7 @@ }, { "command": "gitlens.showLineHistoryView", - "when": "gitlens:enabled" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.showRemotesView", @@ -5670,7 +5670,7 @@ }, { "command": "gitlens.showRepositoriesView", - "when": "gitlens:enabled" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.showSearchAndCompareView", @@ -5678,7 +5678,7 @@ }, { "command": "gitlens.showStashesView", - "when": "gitlens:enabled" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.showTagsView", @@ -5694,23 +5694,23 @@ }, { "command": "gitlens.compareWith", - "when": "gitlens:enabled" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.compareHeadWith", - "when": "gitlens:enabled" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.compareWorkingWith", - "when": "gitlens:enabled" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.diffDirectory", - "when": "gitlens:enabled" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.diffDirectoryWithHead", - "when": "gitlens:enabled" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.diffWithRevisionFrom", @@ -5774,11 +5774,11 @@ }, { "command": "gitlens.externalDiff", - "when": "gitlens:activeFileStatus =~ /tracked/" + "when": "!gitlens:hasVirtualFolders && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.externalDiffAll", - "when": "gitlens:enabled" + "when": "gitlens:enabled && !gitlens:hasVirtualFolders" }, { "command": "gitlens.toggleFileBlame", @@ -5830,39 +5830,39 @@ }, { "command": "gitlens.gitCommands", - "when": "!gitlens:disabled && !gitlens:readonly" + "when": "!gitlens:disabled" }, { "command": "gitlens.gitCommands.branch", - "when": "!gitlens:disabled && !gitlens:readonly" + "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.gitCommands.cherryPick", - "when": "!gitlens:disabled && !gitlens:readonly" + "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.gitCommands.merge", - "when": "!gitlens:disabled && !gitlens:readonly" + "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.gitCommands.rebase", - "when": "!gitlens:disabled && !gitlens:readonly" + "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.gitCommands.reset", - "when": "!gitlens:disabled && !gitlens:readonly" + "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.gitCommands.revert", - "when": "!gitlens:disabled && !gitlens:readonly" + "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.gitCommands.switch", - "when": "!gitlens:disabled && !gitlens:readonly" + "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.gitCommands.tag", - "when": "!gitlens:disabled && !gitlens:readonly" + "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.switchMode", @@ -6106,7 +6106,7 @@ }, { "command": "gitlens.stashApply", - "when": "gitlens:enabled && !gitlens:readonly" + "when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.views.deleteStash", @@ -6114,7 +6114,7 @@ }, { "command": "gitlens.stashSave", - "when": "gitlens:enabled && !gitlens:readonly" + "when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.stashSaveFiles", @@ -6134,19 +6134,19 @@ }, { "command": "gitlens.browseRepoAtRevision", - "when": "gitlens:activeFileStatus =~ /revision/" + "when": "!gitlens:hasVirtualFolders && gitlens:activeFileStatus =~ /revision/" }, { "command": "gitlens.browseRepoAtRevisionInNewWindow", - "when": "gitlens:activeFileStatus =~ /revision/" + "when": "!gitlens:hasVirtualFolders && gitlens:activeFileStatus =~ /revision/" }, { "command": "gitlens.browseRepoBeforeRevision", - "when": "gitlens:activeFileStatus =~ /revision/" + "when": "!gitlens:hasVirtualFolders && gitlens:activeFileStatus =~ /revision/" }, { "command": "gitlens.browseRepoBeforeRevisionInNewWindow", - "when": "gitlens:activeFileStatus =~ /revision/" + "when": "!gitlens:hasVirtualFolders && gitlens:activeFileStatus =~ /revision/" }, { "command": "gitlens.views.browseRepoAtRevision", @@ -6166,15 +6166,15 @@ }, { "command": "gitlens.fetchRepositories", - "when": "gitlens:hasRemotes && !gitlens:readonly" + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.pullRepositories", - "when": "gitlens:hasRemotes && !gitlens:readonly" + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.pushRepositories", - "when": "gitlens:hasRemotes && !gitlens:readonly" + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { "command": "gitlens.views.addRemote", @@ -7301,7 +7301,7 @@ "git.commit": [ { "command": "gitlens.addAuthors", - "when": "gitlens:enabled && !gitlens:readonly && config.gitlens.menus.scm.authors", + "when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && config.gitlens.menus.scm.authors", "group": "4_gitlens@1" } ], @@ -7320,12 +7320,12 @@ "scm/resourceGroup/context": [ { "command": "gitlens.stashSave", - "when": "gitlens:enabled && !gitlens:readonly && scmProvider == git && scmResourceGroup =~ /^(workingTree|index)$/ && config.gitlens.menus.scmGroupInline.stash", + "when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && scmProvider == git && scmResourceGroup =~ /^(workingTree|index)$/ && config.gitlens.menus.scmGroupInline.stash", "group": "inline@-1" }, { "command": "gitlens.stashSave", - "when": "gitlens:enabled && !gitlens:readonly && scmProvider == git && scmResourceGroup =~ /^(workingTree|index)$/ && config.gitlens.menus.scmGroup.stash", + "when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && scmProvider == git && scmResourceGroup =~ /^(workingTree|index)$/ && config.gitlens.menus.scmGroup.stash", "group": "1_modification@100" }, { @@ -7364,7 +7364,7 @@ }, { "command": "gitlens.stashSaveFiles", - "when": "gitlens:enabled && !gitlens:readonly && scmProvider == git && scmResourceGroup =~ /^(workingTree|index)$/ && config.gitlens.menus.scmItem.stash", + "when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && scmProvider == git && scmResourceGroup =~ /^(workingTree|index)$/ && config.gitlens.menus.scmItem.stash", "group": "1_modification@2" }, { @@ -7399,12 +7399,12 @@ }, { "command": "gitlens.views.switchToAnotherBranch", - "when": "!gitlens:readonly && view =~ /^gitlens\\.views\\.branches/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.branches/", "group": "navigation@10" }, { "command": "gitlens.views.createBranch", - "when": "!gitlens:readonly && view =~ /gitlens\\.views\\.branches\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /gitlens\\.views\\.branches\\b/", "group": "navigation@11" }, { @@ -7469,22 +7469,22 @@ }, { "command": "gitlens.pushRepositories", - "when": "gitlens:hasRemotes && !gitlens:readonly && view =~ /^gitlens\\.views\\.commits/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.commits/", "group": "navigation@1" }, { "command": "gitlens.pullRepositories", - "when": "gitlens:hasRemotes && !gitlens:readonly && view =~ /^gitlens\\.views\\.commits/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.commits/", "group": "navigation@2" }, { "command": "gitlens.fetchRepositories", - "when": "gitlens:hasRemotes && !gitlens:readonly && view =~ /^gitlens\\.views\\.commits/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.commits/", "group": "navigation@3" }, { "command": "gitlens.views.switchToAnotherBranch", - "when": "!gitlens:readonly && view =~ /^gitlens\\.views\\.commits/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.commits/", "group": "navigation@10" }, { @@ -7554,7 +7554,7 @@ }, { "command": "gitlens.showRepositoriesView", - "when": "view =~ /^gitlens\\.views\\.commits/", + "when": "!gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.commits/", "group": "8_gitlens_toggles@0" }, { @@ -7679,7 +7679,7 @@ }, { "command": "gitlens.showLineHistoryView", - "when": "view =~ /^gitlens\\.views\\.fileHistory/", + "when": "!gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.fileHistory/", "group": "8_gitlens_toggles@0" }, { @@ -7714,7 +7714,7 @@ }, { "command": "gitlens.views.addRemote", - "when": "!gitlens:readonly && view =~ /gitlens\\.views\\.remotes/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /gitlens\\.views\\.remotes/", "group": "navigation@1" }, { @@ -7769,17 +7769,17 @@ }, { "command": "gitlens.pushRepositories", - "when": "gitlens:hasRemotes && !gitlens:readonly && view =~ /^gitlens\\.views\\.repositories/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.repositories/", "group": "navigation@1" }, { "command": "gitlens.pullRepositories", - "when": "gitlens:hasRemotes && !gitlens:readonly && view =~ /^gitlens\\.views\\.repositories/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.repositories/", "group": "navigation@2" }, { "command": "gitlens.fetchRepositories", - "when": "gitlens:hasRemotes && !gitlens:readonly && view =~ /^gitlens\\.views\\.repositories/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.repositories/", "group": "navigation@3" }, { @@ -7879,12 +7879,12 @@ }, { "command": "gitlens.stashSave", - "when": "!gitlens:readonly && view =~ /^gitlens\\.views\\.stashes/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.stashes/", "group": "navigation@10" }, { "command": "gitlens.stashApply", - "when": "!gitlens:readonly && view =~ /^gitlens\\.views\\.stashes/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.stashes/", "group": "navigation@11" }, { @@ -7909,7 +7909,7 @@ }, { "command": "gitlens.views.createTag", - "when": "!gitlens:readonly && view =~ /gitlens\\.views\\.tags\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && view =~ /gitlens\\.views\\.tags\\b/", "group": "navigation@10" }, { @@ -8016,12 +8016,12 @@ "view/item/context": [ { "command": "gitlens.views.switchToAnotherBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branches\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branches\\b/", "group": "inline@10" }, { "command": "gitlens.views.createBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branches\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branches\\b/", "group": "inline@11" }, { @@ -8042,12 +8042,12 @@ }, { "command": "gitlens.views.switchToAnotherBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branches\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branches\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.createBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branches\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branches\\b/", "group": "1_gitlens_actions@2" }, { @@ -8068,52 +8068,52 @@ }, { "command": "gitlens.views.switchToBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", "group": "inline@7" }, { "command": "gitlens.views.switchToAnotherBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)/", "group": "inline@7" }, { "command": "gitlens.views.publishBranch", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+tracking\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+tracking\\b)/", "group": "inline@8" }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/", "group": "inline@8" }, { "command": "gitlens.views.pull", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+behind\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+behind\\b)/", "group": "inline@8" }, { "command": "gitlens.views.fetch", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(remote|tracking)\\b)(?!.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(remote|tracking)\\b)(?!.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/", "group": "inline@8" }, { "command": "gitlens.views.createPullRequest", - "when": "gitlens:hasRemotes && !gitlens:readonly && gitlens:action:createPullRequest && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(tracking|remote)\\b)/", + "when": "gitlens:hasRemotes && gitlens:action:createPullRequest && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(tracking|remote)\\b)/", "group": "inline@9" }, { "command": "gitlens.views.undoCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+HEAD\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+HEAD\\b)/", "group": "inline@95" }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?=.*?\\b\\+HEAD\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?=.*?\\b\\+HEAD\\b)/", "group": "inline@96" }, { "command": "gitlens.views.pushToCommit", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?!.*?\\b\\+HEAD\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?!.*?\\b\\+HEAD\\b)/", "group": "inline@96" }, { @@ -8145,52 +8145,52 @@ }, { "command": "gitlens.views.switchToAnotherBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.switchToBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.mergeBranchInto", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@3" }, { "command": "gitlens.views.rebaseOntoBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@4" }, { "command": "gitlens.views.rebaseOntoUpstream", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+tracking\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+tracking\\b)/", "group": "1_gitlens_actions@4" }, { "command": "gitlens.views.renameBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b/", "group": "1_gitlens_actions@5" }, { "command": "gitlens.views.deleteBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@6" }, { "command": "gitlens.views.createBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b/", "group": "1_gitlens_actions_@7" }, { "command": "gitlens.views.createTag", - "when": "!gitlens:readonly && viewItem =~ /gitlens:branch\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b/", "group": "1_gitlens_actions_@8" }, { "command": "gitlens.views.createPullRequest", - "when": "gitlens:hasRemotes && !gitlens:readonly && gitlens:action:createPullRequest && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(tracking|remote)\\b)/", + "when": "gitlens:hasRemotes && gitlens:action:createPullRequest && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(tracking|remote)\\b)/", "group": "1_gitlens_actions_@9" }, { @@ -8201,37 +8201,37 @@ }, { "command": "gitlens.views.openDirectoryDiffWithWorking", - "when": "viewItem =~ /gitlens:(branch|tag)\\b/", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:(branch|tag)\\b/", "group": "3_gitlens_explore@11" }, { "command": "gitlens.views.compareWithUpstream", - "when": "viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+tracking\\b)/", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?=.*?\\b\\+tracking\\b)/", "group": "4_gitlens_compare@1" }, { "command": "gitlens.views.compareWithHead", - "when": "viewItem =~ /gitlens:(branch\\b(?!.*?\\b\\+current\\b)|commit\\b|stash\\b|tag\\b)/", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:(branch\\b(?!.*?\\b\\+current\\b)|commit\\b|stash\\b|tag\\b)/", "group": "4_gitlens_compare@2" }, { "command": "gitlens.views.compareWithWorking", - "when": "viewItem =~ /gitlens:(branch|commit|stash|tag)\\b/", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:(branch|commit|stash|tag)\\b/", "group": "4_gitlens_compare@3" }, { "command": "gitlens.views.compareAncestryWithWorking", - "when": "viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/", "group": "4_gitlens_compare@4" }, { "command": "gitlens.views.compareWithSelected", - "when": "viewItem =~ /gitlens:(branch|commit|stash|tag)\\b/ && gitlens:views:canCompare", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:(branch|commit|stash|tag)\\b/ && gitlens:views:canCompare", "group": "4_gitlens_compare@98" }, { "command": "gitlens.views.selectForCompare", - "when": "viewItem =~ /gitlens:(branch|commit|stash|tag)\\b/", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:(branch|commit|stash|tag)\\b/", "group": "4_gitlens_compare@99" }, { @@ -8303,57 +8303,57 @@ }, { "command": "gitlens.views.cherryPick", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?!.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?!.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.undoCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+HEAD\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+HEAD\\b)/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?=.*?\\b\\+HEAD\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?=.*?\\b\\+HEAD\\b)/", "group": "1_gitlens_actions@2" }, { "command": "gitlens.views.pushToCommit", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?!.*?\\b\\+HEAD\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?!.*?\\b\\+HEAD\\b)/", "group": "1_gitlens_actions@2" }, { "command": "gitlens.views.revert", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@3" }, { "command": "gitlens.views.resetToCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@4" }, { "command": "gitlens.views.resetCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@5" }, { "command": "gitlens.views.rebaseOntoCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b/", "group": "1_gitlens_actions@6" }, { "command": "gitlens.views.switchToCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b/", "group": "1_gitlens_actions@7" }, { "command": "gitlens.views.createBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b/", "group": "1_gitlens_actions_1@1" }, { "command": "gitlens.views.createTag", - "when": "!gitlens:readonly && viewItem =~ /gitlens:commit\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b/", "group": "1_gitlens_actions_1@2" }, { @@ -8389,17 +8389,17 @@ }, { "command": "gitlens.views.undoCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+HEAD\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+HEAD\\b)/", "group": "inline@-2" }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?=.*?\\b\\+HEAD\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?=.*?\\b\\+HEAD\\b)/", "group": "inline@-1" }, { "command": "gitlens.views.pushToCommit", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?!.*?\\b\\+HEAD\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?!.*?\\b\\+HEAD\\b)/", "group": "inline@-1" }, { @@ -8431,12 +8431,12 @@ }, { "command": "gitlens.views.stageFile", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+unstaged\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+unstaged\\b)/", "group": "inline@97" }, { "command": "gitlens.views.unstageFile", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+staged\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+staged\\b)/", "group": "inline@97" }, { @@ -8453,17 +8453,17 @@ }, { "command": "gitlens.views.stageFile", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+unstaged\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+unstaged\\b)/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.unstageFile", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+staged\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+staged\\b)/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.stashSaveFiles", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+(un)?staged\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+(un)?staged\\b)/", "group": "1_gitlens_actions@2" }, { @@ -8505,37 +8505,37 @@ }, { "submenu": "gitlens/commit/file/commit", - "when": "!gitlens:readonly && view =~ /^gitlens\\.views\\.(fileHistory|lineHistory)/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "when": "view =~ /^gitlens\\.views\\.(fileHistory|lineHistory)/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", "group": "3_gitlens_explore@1" }, { "command": "gitlens.views.compareWithHead", - "when": "view =~ /^gitlens\\.views\\.(fileHistory|lineHistory)/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "when": "!gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.(fileHistory|lineHistory)/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", "group": "4_gitlens_compare@2" }, { "command": "gitlens.views.compareWithWorking", - "when": "view =~ /^gitlens\\.views\\.(fileHistory|lineHistory)/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "when": "!gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.(fileHistory|lineHistory)/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", "group": "4_gitlens_compare@3" }, { "command": "gitlens.views.applyChanges", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+stashed\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+stashed\\b)/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.restore", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+stashed\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+stashed\\b)/", "group": "1_gitlens_actions@2" }, { "command": "gitlens.views.applyChanges", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b((?=.*?\\b\\+committed\\b)|:results\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b((?=.*?\\b\\+committed\\b)|:results\\b)/", "group": "8_gitlens_actions@1" }, { "command": "gitlens.views.restore", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b((?=.*?\\b\\+committed\\b)|:results\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b((?=.*?\\b\\+committed\\b)|:results\\b)/", "group": "8_gitlens_actions@2" }, { @@ -8580,7 +8580,7 @@ }, { "command": "gitlens.views.addRemote", - "when": "!gitlens:readonly && viewItem =~ /gitlens:remotes\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:remotes\\b/", "group": "inline@1" }, { @@ -8595,12 +8595,12 @@ }, { "command": "gitlens.views.addRemote", - "when": "!gitlens:readonly && viewItem =~ /gitlens:remotes\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:remotes\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.fetch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:remote\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:remote\\b/", "group": "inline@97" }, { @@ -8621,12 +8621,12 @@ }, { "command": "gitlens.views.fetch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:remote\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:remote\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.pruneRemote", - "when": "!gitlens:readonly && viewItem =~ /gitlens:remote\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:remote\\b/", "group": "1_gitlens_actions@2" }, { @@ -8643,7 +8643,7 @@ }, { "command": "gitlens.views.terminalRemoveRemote", - "when": "!gitlens:readonly && viewItem =~ /gitlens:remote\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:remote\\b/", "group": "6_gitlens_terminal@1" }, { @@ -8668,23 +8668,23 @@ }, { "submenu": "gitlens/commit/browse", - "when": "viewItem =~ /gitlens:(branch|commit|file\\b(?=.*?\\b\\+committed\\b)|stash|tag)\\b/", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:(branch|commit|file\\b(?=.*?\\b\\+committed\\b)|stash|tag)\\b/", "group": "3_gitlens_explore@10" }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "inline@96", "alt": "gitlens.views.pushWithForce" }, { "command": "gitlens.views.pull", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "inline@97" }, { "command": "gitlens.views.fetch", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "inline@98" }, { @@ -8699,27 +8699,27 @@ }, { "command": "gitlens.views.fetch", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.pull", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.pushWithForce", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repository\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "1_gitlens_actions@2" }, { "command": "gitlens.views.openInTerminal", - "when": "viewItem =~ /gitlens:repository\\b/", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "2_gitlens_quickopen@1" }, { @@ -8735,12 +8735,12 @@ }, { "command": "gitlens.stashSave", - "when": "!gitlens:readonly && viewItem =~ /gitlens:repository\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "1_gitlens_actions_1@1" }, { "command": "gitlens.stashApply", - "when": "!gitlens:readonly && viewItem =~ /gitlens:repository\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repository\\b/", "group": "1_gitlens_actions_1@2" }, { @@ -8760,18 +8760,18 @@ }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repo-folder\\b(?=.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b(?=.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/", "group": "inline@96", "alt": "gitlens.views.pushWithForce" }, { "command": "gitlens.views.pull", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repo-folder\\b(?=.*?\\b\\+behind\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b(?=.*?\\b\\+behind\\b)/", "group": "inline@97" }, { "command": "gitlens.views.fetch", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repo-folder\\b(?!.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b(?!.*?\\b\\+ahead\\b)(?!.*?\\b\\+behind\\b)/", "group": "inline@98" }, { @@ -8786,27 +8786,27 @@ }, { "command": "gitlens.views.fetch", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repo-folder\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.pull", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repo-folder\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repo-folder\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.pushWithForce", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:repo-folder\\b/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b/", "group": "1_gitlens_actions@2" }, { "command": "gitlens.views.openInTerminal", - "when": "viewItem =~ /gitlens:repo-folder\\b/", + "when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b/", "group": "2_gitlens_quickopen@1" }, { @@ -8822,12 +8822,12 @@ }, { "command": "gitlens.stashSave", - "when": "!gitlens:readonly && viewItem =~ /gitlens:repo-folder\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b/", "group": "1_gitlens_actions_1@1" }, { "command": "gitlens.stashApply", - "when": "!gitlens:readonly && viewItem =~ /gitlens:repo-folder\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:repo-folder\\b/", "group": "1_gitlens_actions_1@2" }, { @@ -8847,84 +8847,84 @@ }, { "command": "gitlens.views.publishRepository", - "when": "!gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/", + "when": "!gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/", "group": "inline@1" }, { "command": "gitlens.views.addRemote", - "when": "!gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/", + "when": "!gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/", "group": "inline@2" }, { "command": "gitlens.views.publishBranch", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status(\\-branch)?:upstream:none/", "group": "inline@1" }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:ahead/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status(\\-branch)?:upstream:ahead/", "group": "inline@1", "alt": "gitlens.views.pushWithForce" }, { "command": "gitlens.views.pull", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:behind/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status(\\-branch)?:upstream:behind/", "group": "inline@1" }, { "command": "gitlens.views.fetch", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status(\\-branch)?:upstream:(?!none)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status(\\-branch)?:upstream:(?!none)/", "group": "inline@2" }, { "command": "gitlens.views.createPullRequest", - "when": "gitlens:hasRemotes && !gitlens:readonly && gitlens:action:createPullRequest && viewItem =~ /gitlens:status:upstream:(?!none)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:action:createPullRequest && viewItem =~ /gitlens:status:upstream:(?!none)/", "group": "inline@3" }, { "command": "gitlens.openBranchOnRemote", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status:upstream:(?!none)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status:upstream:(?!none)/", "group": "inline@99", "alt": "gitlens.copyRemoteBranchUrl" }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:ahead", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:status:upstream:ahead", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.pushWithForce", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:ahead", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:status:upstream:ahead", "group": "1_gitlens_actions@2" }, { "command": "gitlens.views.pull", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem == gitlens:status:upstream:behind", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:status:upstream:behind", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.fetch", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status:upstream:(?!none)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status:upstream:(?!none)/", "group": "1_gitlens_actions@3" }, { "command": "gitlens.views.createBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:status:upstream/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status:upstream/", "group": "1_gitlens_secondary_actions@1" }, { "command": "gitlens.views.createTag", - "when": "!gitlens:readonly && viewItem =~ /gitlens:status:upstream/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status:upstream/", "group": "1_gitlens_secondary_actions@2" }, { "command": "gitlens.views.createPullRequest", - "when": "gitlens:hasRemotes && !gitlens:readonly && gitlens:action:createPullRequest && viewItem =~ /gitlens:status:upstream:(?!none)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:action:createPullRequest && viewItem =~ /gitlens:status:upstream:(?!none)/", "group": "1_gitlens_secondary_actions@3" }, { "command": "gitlens.openBranchOnRemote", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:status:upstream:(?!none)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:status:upstream:(?!none)/", "group": "2_gitlens_quickopen@1", "alt": "gitlens.copyRemoteBranchUrl" }, @@ -9067,92 +9067,92 @@ }, { "command": "gitlens.stashSave", - "when": "!gitlens:readonly && viewItem =~ /^gitlens:(stashes|status:files)$/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /^gitlens:(stashes|status:files)$/", "group": "inline@98" }, { "command": "gitlens.stashApply", - "when": "!gitlens:readonly && viewItem == gitlens:stashes", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:stashes", "group": "inline@99" }, { "command": "gitlens.stashSave", - "when": "!gitlens:readonly && viewItem =~ /^gitlens:(stashes|status:files)$/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /^gitlens:(stashes|status:files)$/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.stashApply", - "when": "!gitlens:readonly && viewItem == gitlens:stashes", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:stashes", "group": "1_gitlens_actions@2" }, { "command": "gitlens.stashApply", - "when": "!gitlens:readonly && viewItem == gitlens:stash", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:stash", "group": "inline@1" }, { "command": "gitlens.views.deleteStash", - "when": "!gitlens:readonly && viewItem == gitlens:stash", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:stash", "group": "inline@99" }, { "command": "gitlens.stashApply", - "when": "!gitlens:readonly && viewItem == gitlens:stash", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:stash", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.deleteStash", - "when": "!gitlens:readonly && viewItem == gitlens:stash", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:stash", "group": "1_gitlens_actions@2" }, { "command": "gitlens.views.createTag", - "when": "!gitlens:readonly && viewItem =~ /gitlens:tags\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:tags\\b/", "group": "inline@1" }, { "command": "gitlens.views.createTag", - "when": "!gitlens:readonly && viewItem =~ /gitlens:tags\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:tags\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.switchToTag", - "when": "!gitlens:readonly && viewItem =~ /gitlens:tag\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:tag\\b/", "group": "inline@10" }, { "command": "gitlens.views.switchToTag", - "when": "!gitlens:readonly && viewItem =~ /gitlens:tag\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:tag\\b/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.deleteTag", - "when": "!gitlens:readonly && viewItem == gitlens:tag", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem == gitlens:tag", "group": "1_gitlens_actions@2" }, { "command": "gitlens.views.createBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:tag\\b/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:tag\\b/", "group": "1_gitlens_actions@3" }, { "command": "gitlens.views.stageDirectory", - "when": "viewItem =~ /gitlens:folder\\b(?=.*?\\b\\+working\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:folder\\b(?=.*?\\b\\+working\\b)/", "group": "inline@1" }, { "command": "gitlens.views.unstageDirectory", - "when": "viewItem =~ /gitlens:folder\\b(?=.*?\\b\\+working\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:folder\\b(?=.*?\\b\\+working\\b)/", "group": "inline@2" }, { "command": "gitlens.views.stageDirectory", - "when": "viewItem =~ /gitlens:folder\\b(?=.*?\\b\\+working\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:folder\\b(?=.*?\\b\\+working\\b)/", "group": "1_gitlens_actions@1" }, { "command": "gitlens.views.unstageDirectory", - "when": "viewItem =~ /gitlens:folder\\b(?=.*?\\b\\+working\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:folder\\b(?=.*?\\b\\+working\\b)/", "group": "1_gitlens_actions@2" }, { @@ -9270,47 +9270,47 @@ }, { "command": "gitlens.views.push", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?=.*?\\b\\+HEAD\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?=.*?\\b\\+HEAD\\b)/", "group": "1_gitlens_actions@0" }, { "command": "gitlens.views.pushToCommit", - "when": "gitlens:hasRemotes && !gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?!.*?\\b\\+HEAD\\b)/", + "when": "gitlens:hasRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+unpublished\\b)(?!.*?\\b\\+HEAD\\b)/", "group": "1_gitlens_actions@0" }, { "command": "gitlens.views.revert", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@3" }, { "command": "gitlens.views.resetToCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@4" }, { "command": "gitlens.views.resetCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@5" }, { "command": "gitlens.views.rebaseOntoCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)(?=.*?\\b\\+current\\b)/", "group": "1_gitlens_actions@6" }, { "command": "gitlens.views.switchToCommit", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", "group": "1_gitlens_actions@7" }, { "command": "gitlens.views.createBranch", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", "group": "1_gitlens_secondary_actions@1" }, { "command": "gitlens.views.createTag", - "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", "group": "1_gitlens_secondary_actions@2" } ], @@ -9335,7 +9335,7 @@ }, { "command": "gitlens.externalDiff", - "when": "viewItem =~ /gitlens:file\\b(?!.*?\\b\\+conflicted\\b)/", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:file\\b(?!.*?\\b\\+conflicted\\b)/", "group": "1_gitlens@5" }, { @@ -9475,31 +9475,34 @@ "gitlens/scm/resourceGroup/changes": [ { "command": "gitlens.externalDiffAll", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders", "group": "1_gitlens@1" }, { "command": "gitlens.diffDirectoryWithHead", + "when": "!gitlens:hasVirtualFolders", "group": "1_gitlens@2" }, { "command": "gitlens.diffDirectory", + "when": "!gitlens:hasVirtualFolders", "group": "1_gitlens@3" } ], "gitlens/scm/resourceState/changes": [ { "command": "gitlens.externalDiff", - "when": "gitlens:enabled && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.compare", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.compare", "group": "navigation" }, { "command": "gitlens.diffWithRevision", - "when": "gitlens:enabled && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.compare", + "when": "!gitlens:hasVirtualFolders && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.compare", "group": "1_gitlens@1" }, { "command": "gitlens.diffWithRevisionFrom", - "when": "gitlens:enabled && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.compare", + "when": "!gitlens:hasVirtualFolders && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.compare", "group": "1_gitlens@2" } ], @@ -9593,7 +9596,7 @@ }, { "command": "gitlens.views.searchAndCompare.selectForCompare", - "when": "view =~ /^gitlens\\.views\\.searchAndCompare\\b/", + "when": "!gitlens:hasVirtualFolders && view =~ /^gitlens\\.views\\.searchAndCompare\\b/", "group": "navigation@11" } ], @@ -10014,7 +10017,8 @@ }, { "view": "gitlens.views.searchAndCompare", - "contents": "Compare a with another \n\n[Compare References...](command:gitlens.views.searchAndCompare.selectForCompare)" + "contents": "Compare a with another \n\n[Compare References...](command:gitlens.views.searchAndCompare.selectForCompare)", + "when": "!gitlens:hasVirtualFolders" } ], "views": { @@ -10040,7 +10044,7 @@ { "id": "gitlens.views.repositories", "name": "Repositories", - "when": "!gitlens:disabled", + "when": "!gitlens:disabled && !gitlens:hasVirtualFolders", "contextualTitle": "GitLens", "icon": "images/views/repositories.svg", "visibility": "hidden" @@ -10056,7 +10060,7 @@ { "id": "gitlens.views.lineHistory", "name": "Line History", - "when": "!gitlens:disabled", + "when": "!gitlens:disabled && !gitlens:hasVirtualFolders", "contextualTitle": "GitLens", "icon": "images/views/history.svg", "visibility": "hidden" @@ -10080,7 +10084,7 @@ { "id": "gitlens.views.stashes", "name": "Stashes", - "when": "!gitlens:disabled", + "when": "!gitlens:disabled && !gitlens:hasVirtualFolders", "contextualTitle": "GitLens", "icon": "images/views/stashes.svg", "visibility": "collapsed" diff --git a/src/commands/git/stash.ts b/src/commands/git/stash.ts index 00e49f2..c63c15e 100644 --- a/src/commands/git/stash.ts +++ b/src/commands/git/stash.ts @@ -1,6 +1,7 @@ import { QuickInputButtons, QuickPickItem, Uri, window } from 'vscode'; -import { GlyphChars } from '../../constants'; +import { ContextKeys, GlyphChars } from '../../constants'; import { Container } from '../../container'; +import { getContext } from '../../context'; import { StashApplyError, StashApplyErrorReason } from '../../git/errors'; import { GitReference, GitStashCommit, GitStashReference, Repository } from '../../git/models'; import { Logger } from '../../logger'; @@ -31,6 +32,7 @@ import { interface Context { repos: Repository[]; associatedView: ViewsWithRepositoryFolders; + readonly: boolean; title: string; } @@ -150,6 +152,10 @@ export class StashGitCommand extends QuickCommand { const context: Context = { repos: this.container.git.openRepositories, associatedView: this.container.stashesView, + readonly: + getContext(ContextKeys.Readonly, false) || + getContext(ContextKeys.Untrusted, false) || + getContext(ContextKeys.HasVirtualFolders, false), title: this.title, }; @@ -158,6 +164,10 @@ export class StashGitCommand extends QuickCommand { while (this.canStepsContinue(state)) { context.title = this.title; + if (context.readonly) { + state.subcommand = 'list'; + } + if (state.counter < 1 || state.subcommand == null) { this.subcommand = undefined; diff --git a/src/commands/gitCommands.utils.ts b/src/commands/gitCommands.utils.ts index 1ece78f..c463cb4 100644 --- a/src/commands/gitCommands.utils.ts +++ b/src/commands/gitCommands.utils.ts @@ -1,5 +1,7 @@ import { GitCommandSorting } from '../config'; +import { ContextKeys } from '../constants'; import type { Container } from '../container'; +import { getContext } from '../context'; import { Usage, WorkspaceState } from '../storage'; import { BranchGitCommand } from './git/branch'; import { CherryPickGitCommand } from './git/cherry-pick'; @@ -50,28 +52,45 @@ export class PickCommandStep implements QuickPickStep { readonly title = 'GitLens'; constructor(private readonly container: Container, args?: GitCommandsCommandArgs) { + const hasVirtualFolders = getContext(ContextKeys.HasVirtualFolders, false); + const readonly = + hasVirtualFolders || + getContext(ContextKeys.Readonly, false) || + getContext(ContextKeys.Untrusted, false); + this.items = [ - new BranchGitCommand(container, args?.command === 'branch' ? args : undefined), - new CherryPickGitCommand(container, args?.command === 'cherry-pick' ? args : undefined), - new CoAuthorsGitCommand(container, args?.command === 'co-authors' ? args : undefined), - new FetchGitCommand(container, args?.command === 'fetch' ? args : undefined), + readonly ? undefined : new BranchGitCommand(container, args?.command === 'branch' ? args : undefined), + readonly + ? undefined + : new CherryPickGitCommand(container, args?.command === 'cherry-pick' ? args : undefined), + hasVirtualFolders + ? undefined + : new CoAuthorsGitCommand(container, args?.command === 'co-authors' ? args : undefined), + readonly ? undefined : new FetchGitCommand(container, args?.command === 'fetch' ? args : undefined), new LogGitCommand(container, args?.command === 'log' ? args : undefined), - new MergeGitCommand(container, args?.command === 'merge' ? args : undefined), - new PullGitCommand(container, args?.command === 'pull' ? args : undefined), - new PushGitCommand(container, args?.command === 'push' ? args : undefined), - new RebaseGitCommand(container, args?.command === 'rebase' ? args : undefined), - new ResetGitCommand(container, args?.command === 'reset' ? args : undefined), - new RevertGitCommand(container, args?.command === 'revert' ? args : undefined), + readonly ? undefined : new MergeGitCommand(container, args?.command === 'merge' ? args : undefined), + readonly ? undefined : new PullGitCommand(container, args?.command === 'pull' ? args : undefined), + readonly ? undefined : new PushGitCommand(container, args?.command === 'push' ? args : undefined), + readonly ? undefined : new RebaseGitCommand(container, args?.command === 'rebase' ? args : undefined), + readonly ? undefined : new ResetGitCommand(container, args?.command === 'reset' ? args : undefined), + readonly ? undefined : new RevertGitCommand(container, args?.command === 'revert' ? args : undefined), new SearchGitCommand(container, args?.command === 'search' || args?.command === 'grep' ? args : undefined), + new ShowGitCommand(container, args?.command === 'show' ? args : undefined), - new StashGitCommand(container, args?.command === 'stash' ? args : undefined), - new StatusGitCommand(container, args?.command === 'status' ? args : undefined), - new SwitchGitCommand( - container, - args?.command === 'switch' || args?.command === 'checkout' ? args : undefined, - ), - new TagGitCommand(container, args?.command === 'tag' ? args : undefined), - ]; + hasVirtualFolders + ? undefined + : new StashGitCommand(container, args?.command === 'stash' ? args : undefined), + hasVirtualFolders + ? undefined + : new StatusGitCommand(container, args?.command === 'status' ? args : undefined), + readonly + ? undefined + : new SwitchGitCommand( + container, + args?.command === 'switch' || args?.command === 'checkout' ? args : undefined, + ), + readonly ? undefined : new TagGitCommand(container, args?.command === 'tag' ? args : undefined), + ].filter((i: T | undefined): i is T => i != null); if (this.container.config.gitCommands.sortBy === GitCommandSorting.Usage) { const usage = this.container.storage.getWorkspace(WorkspaceState.GitCommandPaletteUsage); diff --git a/src/constants.ts b/src/constants.ts index 14db104..518d1c2 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -242,7 +242,9 @@ export const enum ContextKeys { HasConnectedRemotes = 'gitlens:hasConnectedRemotes', HasRemotes = 'gitlens:hasRemotes', HasRichRemotes = 'gitlens:hasRichRemotes', + HasVirtualFolders = 'gitlens:hasVirtualFolders', Readonly = 'gitlens:readonly', + Untrusted = 'gitlens:untrusted', ViewsCanCompare = 'gitlens:views:canCompare', ViewsCanCompareFile = 'gitlens:views:canCompare:file', ViewsCommitsMyCommitsOnly = 'gitlens:views:commits:myCommitsOnly', diff --git a/src/context.ts b/src/context.ts index 0b93238..403f567 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,16 +1,18 @@ import { commands } from 'vscode'; import { ContextKeys, CoreCommands } from './constants'; -// const contextStorage = new Map(); +const contextStorage = new Map(); -// export function getContext(key: ContextKeys): unknown | undefined { -// return contextStorage.get(key); -// } +export function getContext(key: ContextKeys): T | undefined; +export function getContext(key: ContextKeys, defaultValue: T): T; +export function getContext(key: ContextKeys, defaultValue?: T): T | undefined { + return (contextStorage.get(key) as T | undefined) ?? defaultValue; +} export async function setContext( key: ContextKeys | `${ContextKeys.ActionPrefix}${string}` | `${ContextKeys.KeyPrefix}${string}`, value: unknown, ): Promise { - // contextStorage.set(key, value); + contextStorage.set(key, value); void (await commands.executeCommand(CoreCommands.SetContext, key, value)); } diff --git a/src/extension.ts b/src/extension.ts index 85aec6b..c70e27b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -60,9 +60,9 @@ export async function activate(context: ExtensionContext): Promise void setContext(ContextKeys.Readonly, undefined)), + workspace.onDidGrantWorkspaceTrust(() => void setContext(ContextKeys.Untrusted, undefined)), ); } diff --git a/src/git/gitProviderService.ts b/src/git/gitProviderService.ts index fe62d4b..c51cf15 100644 --- a/src/git/gitProviderService.ts +++ b/src/git/gitProviderService.ts @@ -27,7 +27,7 @@ import { WorkspaceState } from '../storage'; import { groupByFilterMap, groupByMap } from '../system/array'; import { gate } from '../system/decorators/gate'; import { debug, log } from '../system/decorators/log'; -import { count, filter, first, flatMap, map } from '../system/iterable'; +import { count, filter, first, flatMap, map, some } from '../system/iterable'; import { dirname, getBestPath, getScheme, isAbsolute, maybeUri, normalizePath } from '../system/path'; import { cancellable, isPromise, PromiseCancelledError } from '../system/promise'; import { VisitedPathsTrie } from '../system/trie'; @@ -427,6 +427,10 @@ export class GitProviderService implements Disposable { return groupByMap(repositories, r => r.provider.id); } + hasOpenRepositories(id: GitProviderId): boolean { + return some(this.repositories, r => !r.closed && (id == null || id === r.provider.id)); + } + private _discoveredWorkspaceFolders = new Map>(); @log({ args: { 0: folders => folders.length } }) diff --git a/src/premium/github/githubGitProvider.ts b/src/premium/github/githubGitProvider.ts index eb4fe28..74babb9 100644 --- a/src/premium/github/githubGitProvider.ts +++ b/src/premium/github/githubGitProvider.ts @@ -15,8 +15,9 @@ import { } from 'vscode'; import { encodeUtf8Hex } from '@env/hex'; import { configuration } from '../../configuration'; -import { CharCode, Schemes } from '../../constants'; +import { CharCode, ContextKeys, Schemes } from '../../constants'; import type { Container } from '../../container'; +import { setContext } from '../../context'; import { AuthenticationError, AuthenticationErrorReason, @@ -156,6 +157,10 @@ export class GitHubGitProvider implements GitProvider, Disposable { } } + updateContext(): void { + void setContext(ContextKeys.HasVirtualFolders, this.container.git.hasOpenRepositories(this.descriptor.id)); + } + openRepository( folder: WorkspaceFolder | undefined, uri: Uri, @@ -1334,10 +1339,30 @@ export class GitHubGitProvider implements GitProvider, Disposable { @log() async getLogForSearch( - _repoPath: string, - _search: SearchPattern, + repoPath: string, + search: SearchPattern, _options?: { limit?: number; ordering?: string | null; skip?: number }, ): Promise { + if (repoPath == null) return undefined; + + const operations = SearchPattern.parseSearchOperations(search.pattern); + + const values = operations.get('commit:'); + if (values != null) { + const commit = await this.getCommit(repoPath, values[0]); + if (commit == null) return undefined; + + return { + repoPath: repoPath, + commits: new Map([[commit.sha, commit]]), + sha: commit.sha, + range: undefined, + count: 1, + limit: 1, + hasMore: false, + }; + } + // TODO@eamodio try implementing with the commit search api return undefined; }