Skip to content

Commit

Permalink
Add GitHub public repo option (#102406)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlave-dev authored Jul 16, 2020
1 parent 90efeb4 commit 9074d57
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions extensions/github/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
folder = pick.folder.uri;
}

let quickpick = vscode.window.createQuickPick<vscode.QuickPickItem & { repo?: string, auth?: 'https' | 'ssh' }>();
let quickpick = vscode.window.createQuickPick<vscode.QuickPickItem & { repo?: string, auth?: 'https' | 'ssh', isPrivate?: boolean }>();
quickpick.ignoreFocusOut = true;

quickpick.placeholder = 'Repository Name';
Expand All @@ -60,14 +60,18 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
quickpick.busy = false;

let repo: string | undefined;
let isPrivate: boolean;

const onDidChangeValue = async () => {
const sanitizedRepo = sanitizeRepositoryName(quickpick.value);

if (!sanitizedRepo) {
quickpick.items = [];
} else {
quickpick.items = [{ label: `$(repo) Publish to GitHub private repository`, description: `$(github) ${owner}/${sanitizedRepo}`, alwaysShow: true, repo: sanitizedRepo }];
quickpick.items = [
{ label: `$(repo) Publish to GitHub private repository`, description: `$(github) ${owner}/${sanitizedRepo}`, alwaysShow: true, repo: sanitizedRepo, isPrivate: true },
{ label: `$(repo) Publish to GitHub public repository`, description: `$(github) ${owner}/${sanitizedRepo}`, alwaysShow: true, repo: sanitizedRepo, isPrivate: false },
];
}
};

Expand All @@ -79,6 +83,7 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
listener.dispose();

repo = pick?.repo;
isPrivate = pick?.isPrivate ?? true;

if (repo) {
try {
Expand Down Expand Up @@ -145,11 +150,11 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
}

const githubRepository = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, title: 'Publish to GitHub' }, async progress => {
progress.report({ message: 'Publishing to GitHub private repository', increment: 25 });
progress.report({ message: `Publishing to GitHub ${isPrivate ? 'private' : 'public'} repository`, increment: 25 });

const res = await octokit.repos.createForAuthenticatedUser({
name: repo!,
private: true
private: isPrivate
});

const createdGithubRepository = res.data;
Expand Down

0 comments on commit 9074d57

Please sign in to comment.