mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Support continue in local clone from remote window (#171134)
This commit is contained in:
parent
7e54126f9e
commit
d61f46dcf7
|
@ -13,6 +13,7 @@
|
|||
"telemetryLogger",
|
||||
"diffCommand",
|
||||
"contribEditorContentMenu",
|
||||
"contribEditSessions",
|
||||
"contribViewsWelcome",
|
||||
"editSessionIdentityProvider",
|
||||
"scmActionButton",
|
||||
|
@ -50,6 +51,13 @@
|
|||
},
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "git.continueInLocalClone",
|
||||
"title": "%command.continueInLocalClone%",
|
||||
"category": "Git",
|
||||
"icon": "$(repo-clone)",
|
||||
"enablement": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && remoteName"
|
||||
},
|
||||
{
|
||||
"command": "git.clone",
|
||||
"title": "%command.clone%",
|
||||
|
@ -706,6 +714,13 @@
|
|||
"category": "Git"
|
||||
}
|
||||
],
|
||||
"continueEditSession": [
|
||||
{
|
||||
"command": "git.continueInLocalClone",
|
||||
"qualifiedName": "%command.continueInLocalClone.qualifiedName%",
|
||||
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && remoteName"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
{
|
||||
"command": "git.stageSelectedRanges",
|
||||
|
@ -728,6 +743,10 @@
|
|||
],
|
||||
"menus": {
|
||||
"commandPalette": [
|
||||
{
|
||||
"command": "git.continueInLocalClone",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "git.clone",
|
||||
"when": "config.git.enabled && !git.missing"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
"displayName": "Git",
|
||||
"description": "Git SCM Integration",
|
||||
"command.continueInLocalClone": "Clone Repository Locally and Open on Desktop...",
|
||||
"command.continueInLocalClone.qualifiedName": "Continue Working in New Local Clone",
|
||||
"command.clone": "Clone",
|
||||
"command.cloneRecursive": "Clone (Recursive)",
|
||||
"command.init": "Initialize Repository",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind, TextDocument, LogOutputChannel, l10n, Memento } from 'vscode';
|
||||
import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind, TextDocument, LogOutputChannel, l10n, Memento, UIKind } from 'vscode';
|
||||
import TelemetryReporter from '@vscode/extension-telemetry';
|
||||
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
|
||||
import { Branch, ForcePushMode, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote } from './api/git';
|
||||
|
@ -661,6 +661,44 @@ export class CommandCenter {
|
|||
}
|
||||
}
|
||||
|
||||
@command('git.continueInLocalClone')
|
||||
async continueInLocalClone(): Promise<Uri | void> {
|
||||
if (this.model.repositories.length === 0) { return; }
|
||||
|
||||
// Pick a single repository to continue working on in a local clone if there's more than one
|
||||
const items = this.model.repositories.reduce<(QuickPickItem & { repository: Repository })[]>((items, repository) => {
|
||||
const remote = repository.remotes.find((r) => r.name === repository.HEAD?.upstream?.remote);
|
||||
if (remote?.pushUrl) {
|
||||
items.push({ repository: repository, label: remote.pushUrl });
|
||||
}
|
||||
return items;
|
||||
}, []);
|
||||
|
||||
let selection = items[0];
|
||||
if (items.length > 1) {
|
||||
const pick = await window.showQuickPick(items, { canPickMany: false, placeHolder: l10n.t('Choose which repository to clone') });
|
||||
if (pick === undefined) { return; }
|
||||
selection = pick;
|
||||
}
|
||||
|
||||
const uri = selection.label;
|
||||
const ref = selection.repository.HEAD?.upstream?.name;
|
||||
|
||||
if (uri !== undefined) {
|
||||
// Launch desktop client if currently in web
|
||||
if (env.uiKind === UIKind.Web) {
|
||||
let target = `${env.uriScheme}://vscode.git/clone?url=${encodeURIComponent(uri)}`;
|
||||
if (ref !== undefined) {
|
||||
target += `&ref=${encodeURIComponent(ref)}`;
|
||||
}
|
||||
return Uri.parse(target);
|
||||
}
|
||||
|
||||
// If already in desktop client, directly clone
|
||||
void this.clone(uri, undefined, { ref: ref });
|
||||
}
|
||||
}
|
||||
|
||||
@command('git.clone')
|
||||
async clone(url?: string, parentPath?: string, options?: { ref?: string }): Promise<void> {
|
||||
await this.cloneRepository(url, parentPath, options);
|
||||
|
|
|
@ -31,7 +31,7 @@ export class GitEditSessionIdentityProvider implements vscode.EditSessionIdentit
|
|||
|
||||
return JSON.stringify({
|
||||
remote: repository.remotes.find((remote) => remote.name === repository.HEAD?.upstream?.remote)?.pushUrl ?? null,
|
||||
ref: repository.HEAD?.name ?? null,
|
||||
ref: repository.HEAD?.upstream?.name ?? null,
|
||||
sha: repository.HEAD?.commit ?? null,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue