mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
feat(git): Added remote url type option (#146124)
* feat(git): Added remote url type option * Modify extension configuration * Simplified code Co-authored-by: Joao Moreno <joao.moreno@microsoft.com>
This commit is contained in:
@@ -53,4 +53,3 @@ export function getOctokit(): Promise<Octokit> {
|
||||
|
||||
return _octokit;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,9 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
|
||||
progress.report({ message: localize('publishing_uploading', "Uploading files"), increment: 25 });
|
||||
|
||||
const branch = await repository.getBranch('HEAD');
|
||||
await repository.addRemote('origin', createdGithubRepository.clone_url);
|
||||
const protocol = vscode.workspace.getConfiguration('github').get<'https' | 'ssh'>('gitProtocol');
|
||||
const remoteUrl = protocol === 'https' ? createdGithubRepository.clone_url : createdGithubRepository.ssh_url;
|
||||
await repository.addRemote('origin', remoteUrl);
|
||||
await repository.push('origin', branch.name, true);
|
||||
|
||||
return createdGithubRepository;
|
||||
|
||||
@@ -73,7 +73,9 @@ async function handlePushError(repository: Repository, remote: Remote, refspec:
|
||||
await repository.renameRemote(remote.name, 'upstream');
|
||||
|
||||
// Issue: what if there's already another `origin` repo?
|
||||
await repository.addRemote('origin', ghRepository.clone_url);
|
||||
const protocol = workspace.getConfiguration('github').get<'https' | 'ssh'>('gitProtocol');
|
||||
const remoteUrl = protocol === 'https' ? ghRepository.clone_url : ghRepository.ssh_url;
|
||||
await repository.addRemote('origin', remoteUrl);
|
||||
|
||||
try {
|
||||
await repository.fetch('origin', remoteName);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { workspace } from 'vscode';
|
||||
import { RemoteSourceProvider, RemoteSource } from './typings/git-base';
|
||||
import { getOctokit } from './auth';
|
||||
import { Octokit } from '@octokit/rest';
|
||||
@@ -14,10 +15,11 @@ function parse(url: string): { owner: string; repo: string } | undefined {
|
||||
}
|
||||
|
||||
function asRemoteSource(raw: any): RemoteSource {
|
||||
const protocol = workspace.getConfiguration('github').get<'https' | 'ssh'>('gitProtocol');
|
||||
return {
|
||||
name: `$(github) ${raw.full_name}`,
|
||||
description: raw.description || undefined,
|
||||
url: raw.clone_url
|
||||
url: protocol === 'https' ? raw.clone_url : raw.ssh_url
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user