From 214889d22c6a9422bae1dc481d6ad7c3b6cf8f2f Mon Sep 17 00:00:00 2001 From: bbanderson Date: Wed, 31 Jul 2024 10:17:34 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BB=B4=ED=8C=8C=EC=9D=BC=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/src/credentials.ts | 20 +++++++++----------- packages/vscode/src/extension.ts | 9 ++++----- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/packages/vscode/src/credentials.ts b/packages/vscode/src/credentials.ts index 6f7b81a5..158401c8 100644 --- a/packages/vscode/src/credentials.ts +++ b/packages/vscode/src/credentials.ts @@ -49,23 +49,21 @@ export class Credentials { } /** Octokit 인스턴스가 없다면, 인증 세션을 새로 만듦으로써, Octokit 인스턴스가 항상 존재하도록 보장한다. */ - private async ensureOctokitInstance(): Promise { - if (!this.octokit) { + private async getOctokitInstance(): Promise { + if (this.octokit) { + return this.octokit; + } else { const session = await vscode.authentication.getSession(GITHUB_AUTH_PROVIDER_ID, SCOPES, { createIfNone: true }); this.octokit = await this.createOctokit(session); + return this.octokit; } } - async getOctokit(): Promise { - await this.ensureOctokitInstance(); - return this.octokit; + async getOctokit(): Promise { + return this.getOctokitInstance(); } - async getAuth(): Promise { - const octokit = await this.getOctokit(); - if (octokit) { - return octokit.auth() as Promise; - } - return undefined; + async getAuth(): Promise { + return (await this.getOctokitInstance()).auth() as Promise; } } diff --git a/packages/vscode/src/extension.ts b/packages/vscode/src/extension.ts index 2fc0c8e6..c5da7b41 100644 --- a/packages/vscode/src/extension.ts +++ b/packages/vscode/src/extension.ts @@ -4,7 +4,7 @@ import * as vscode from "vscode"; import { COMMAND_LAUNCH, COMMAND_LOGIN_WITH_GITHUB, COMMAND_RESET_GITHUB_AUTH } from "./commands"; import { Credentials } from "./credentials"; import { GithubTokenUndefinedError, WorkspacePathUndefinedError } from "./errors/ExtensionError"; -import { deleteGithubToken, getGithubToken, setGithubToken, } from "./setting-repository"; +import { deleteGithubToken, getGithubToken, setGithubToken } from "./setting-repository"; import { mapClusterNodesFrom } from "./utils/csm.mapper"; import { findGit, @@ -18,7 +18,7 @@ import { import WebviewLoader from "./webview-loader"; let myStatusBarItem: vscode.StatusBarItem; -const projectName = 'githru'; +const projectName = "githru"; function normalizeFsPath(fsPath: string) { return fsPath.replace(/\\/g, "/"); @@ -58,12 +58,11 @@ export async function activate(context: vscode.ExtensionContext) { const fetchBranches = async () => await getBranches(gitPath, currentWorkspacePath); const fetchCurrentBranch = async () => { - let branchName; try { - branchName = await getCurrentBranchName(gitPath, currentWorkspacePath) + branchName = await getCurrentBranchName(gitPath, currentWorkspacePath); } catch (error) { - console.error(error); + console.error(error); } if (!branchName) {