-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Description
Problem
As noted in #102268, the lack of an option to create a public repository is by design rather than a bug. In that issue, @joaomoreno gave the following reason for omitting the option:
We didn't want to overcomplicate this UI, especially since it's fairly straightforward to make the repository public after you create it in GitHub.
I would argue that:
- Having two quickpick options instead of one would not significantly complicate the UI.
- The process of making a private repository public is not straightforward, especially when the alternative is to just create it as public in the first place. For reference, here are the required steps:
-
Select "Publish to GitHub private repository" from quickpick and open the repo when finished.
-
-
-
Open repository settings on GitHub.
-
-
Scroll all the way to the bottom of the page (to the "Danger Zone") and click "Change visibility."
-
-
In the modal, select the "Make public" radio option.
-
Type the full repo name and click "I understand, change repository visibility."
-
For me and many others whose primary work is done in public repos, these steps would be completely eliminated if there were an option to create the repo as public in the first place.
Proposal
I don't believe it would be very difficult to implement this feature. Here's a simple solution:
diff --git a/extensions/github/src/publish.ts b/extensions/github/src/publish.ts
index 589bd0d3d3..9105a4bc8e 100644
--- a/extensions/github/src/publish.ts
+++ b/extensions/github/src/publish.ts
@@ -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';
@@ -60,6 +60,7 @@ 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);
@@ -67,7 +68,10 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
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 },
+ ];
}
};
@@ -79,6 +83,7 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
listener.dispose();
repo = pick?.repo;
+ isPrivate = pick?.isPrivate ?? true;
if (repo) {
try {
@@ -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;