mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Removes Open repository command for now
Until we stabilize the uris want to limit the visibility of this
This commit is contained in:
@@ -10,7 +10,7 @@ import { GitHubApiContext, GitHubApi } from './github/api';
|
||||
import { GitHubFS } from './github/fs';
|
||||
import { VirtualSCM } from './scm';
|
||||
|
||||
const repositoryRegex = /^(?:(?:https:\/\/)?github.com\/)?([^\/]+)\/([^\/]+?)(?:\/|.git|$)/i;
|
||||
// const repositoryRegex = /^(?:(?:https:\/\/)?github.com\/)?([^\/]+)\/([^\/]+?)(?:\/|.git|$)/i;
|
||||
|
||||
export function activate(context: ExtensionContext) {
|
||||
const contextStore = new ContextStore<GitHubApiContext>(context.workspaceState, GitHubFS.scheme);
|
||||
@@ -27,34 +27,34 @@ export function activate(context: ExtensionContext) {
|
||||
new VirtualSCM(GitHubFS.scheme, githubApi, changeStore)
|
||||
);
|
||||
|
||||
commands.registerCommand('githubBrowser.openRepository', async () => {
|
||||
const value = await window.showInputBox({
|
||||
placeHolder: 'e.g. https://github.com/microsoft/vscode',
|
||||
prompt: 'Enter a GitHub repository url',
|
||||
validateInput: value => repositoryRegex.test(value) ? undefined : 'Invalid repository url'
|
||||
});
|
||||
// commands.registerCommand('githubBrowser.openRepository', async () => {
|
||||
// const value = await window.showInputBox({
|
||||
// placeHolder: 'e.g. https://github.com/microsoft/vscode',
|
||||
// prompt: 'Enter a GitHub repository url',
|
||||
// validateInput: value => repositoryRegex.test(value) ? undefined : 'Invalid repository url'
|
||||
// });
|
||||
|
||||
if (value) {
|
||||
const match = repositoryRegex.exec(value);
|
||||
if (match) {
|
||||
const [, owner, repo] = match;
|
||||
// if (value) {
|
||||
// const match = repositoryRegex.exec(value);
|
||||
// if (match) {
|
||||
// const [, owner, repo] = match;
|
||||
|
||||
const uri = Uri.parse(`codespace://HEAD/${owner}/${repo}`);
|
||||
openWorkspace(uri, repo, 'currentWindow');
|
||||
}
|
||||
}
|
||||
});
|
||||
// const uri = Uri.parse(`codespace://HEAD/${owner}/${repo}`);
|
||||
// openWorkspace(uri, repo, 'currentWindow');
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
export function getRootUri(uri: Uri) {
|
||||
return workspace.getWorkspaceFolder(uri)?.uri;
|
||||
}
|
||||
|
||||
function openWorkspace(uri: Uri, name: string, location: 'currentWindow' | 'newWindow' | 'addToCurrentWorkspace') {
|
||||
if (location === 'addToCurrentWorkspace') {
|
||||
const count = (workspace.workspaceFolders && workspace.workspaceFolders.length) || 0;
|
||||
return workspace.updateWorkspaceFolders(count, 0, { uri: uri, name: name });
|
||||
}
|
||||
// function openWorkspace(uri: Uri, name: string, location: 'currentWindow' | 'newWindow' | 'addToCurrentWorkspace') {
|
||||
// if (location === 'addToCurrentWorkspace') {
|
||||
// const count = (workspace.workspaceFolders && workspace.workspaceFolders.length) || 0;
|
||||
// return workspace.updateWorkspaceFolders(count, 0, { uri: uri, name: name });
|
||||
// }
|
||||
|
||||
return commands.executeCommand('vscode.openFolder', uri, location === 'newWindow');
|
||||
}
|
||||
// return commands.executeCommand('vscode.openFolder', uri, location === 'newWindow');
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user