github: publish workspace folder

This commit is contained in:
João Moreno
2020-05-19 11:57:34 +02:00
parent 2aa9f3f243
commit 4bb364cc8e
6 changed files with 155 additions and 114 deletions

View File

@@ -3,9 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { RemoteSourceProvider, RemoteSource } from './typings/git';
import { API as GitAPI, RemoteSourceProvider, RemoteSource, Repository } from './typings/git';
import { getOctokit } from './auth';
import { Octokit } from '@octokit/rest';
import { publishRepository } from './publish';
function asRemoteSource(raw: any): RemoteSource {
return {
@@ -23,6 +24,8 @@ export class GithubRemoteSourceProvider implements RemoteSourceProvider {
private userReposCache: RemoteSource[] = [];
constructor(private gitAPI: GitAPI) { }
async getRemoteSources(query?: string): Promise<RemoteSource[]> {
const octokit = await getOctokit();
const [fromUser, fromQuery] = await Promise.all([
@@ -57,4 +60,8 @@ export class GithubRemoteSourceProvider implements RemoteSourceProvider {
const raw = await octokit.search.repos({ q: query, sort: 'updated' });
return raw.data.items.map(asRemoteSource);
}
publishRepository(repository: Repository): Promise<void> {
return publishRepository(this.gitAPI, repository);
}
}