Skip to content

Add public repository option in "Publish to GitHub" #102306

@jlave-dev

Description

@jlave-dev

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:

  1. Having two quickpick options instead of one would not significantly complicate the UI.
  2. 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.

  • Screen Shot 2020-07-12 at 11 26 12 AM
  • Screen Shot 2020-07-12 at 11 27 26 AM
  • Open repository settings on GitHub.

  • Screen Shot 2020-07-12 at 11 34 14 AM
  • Scroll all the way to the bottom of the page (to the "Danger Zone") and click "Change visibility."

  • Screen Shot 2020-07-12 at 11 28 27 AM
  • In the modal, select the "Make public" radio option.

  • Type the full repo name and click "I understand, change repository visibility."

  • Screen Shot 2020-07-12 at 11 28 51 AM

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;

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalitygithubGithub extensionhelp wantedIssues identified as good community contribution opportunitiesinsiders-releasedPatch has been released in VS Code Insiderson-release-notesIssue/pull request mentioned in release notesverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions