Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated github auth scope to repo #832

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/commands/draft/draftCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ type DraftDependencies = {

async function getGitHubAuthenticationSession(): Promise<Errorable<AuthenticationSession>> {
try {
// No special scopes are required for GitHub - we are just listing repositories/branches.
const scopes: string[] = [];
// Repo scope required to see public/private repos.
ReinierCC marked this conversation as resolved.
Show resolved Hide resolved
// Reference for Github scopes: https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
const scopes: string[] = ["repo"];
const session = await authentication.getSession("github", scopes, { createIfNone: true });
return { succeeded: true, result: session };
} catch (e) {
Expand All @@ -229,13 +230,12 @@ async function getRepo(octokit: Octokit, remote: Remote): Promise<GitHubRepo | n
return null;
}

const [owner, repo] = url
.replace(/\.git$/, "")
.split("/")
.slice(-2);
const parts = url.replace(/\.git$/, "").split(/[:/]/); //Split on both : and /, Removes .git
const [owner, repo] = parts.slice(-2);

let response: RestEndpointMethodTypes["repos"]["get"]["response"];
try {
response = await octokit.repos.get({ owner, repo });
response = await octokit.rest.repos.get({ owner, repo });
Tatsinnit marked this conversation as resolved.
Show resolved Hide resolved
} catch (e) {
return null;
}
Expand Down
Loading