From 40798e1f12dbdc5aa0d496a624ee695b3ece1ea3 Mon Sep 17 00:00:00 2001 From: yuiseo <24oesiu@gmail.com> Date: Thu, 1 Aug 2024 19:58:45 +0900 Subject: [PATCH] =?UTF-8?q?Refactor:=20#448=20parameter=EC=97=90=EC=84=9C?= =?UTF-8?q?=20gitpath=EA=B4=80=EB=A0=A8=20await=20=EC=A0=9C=EA=B1=B0=20Co-?= =?UTF-8?q?authored-by:=20DaYoung-woo=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/src/webview-loader.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/vscode/src/webview-loader.ts b/packages/vscode/src/webview-loader.ts index 0f812c88..ae4292f1 100644 --- a/packages/vscode/src/webview-loader.ts +++ b/packages/vscode/src/webview-loader.ts @@ -24,7 +24,7 @@ function normalizeFsPath(fsPath: string) { export default class WebviewLoader implements vscode.Disposable { private readonly _panel: vscode.WebviewPanel | undefined; githubToken: string | undefined; - gitPath: string | undefined; + gitPath: string; constructor( private readonly extensionPath: string, context: vscode.ExtensionContext, @@ -32,6 +32,8 @@ export default class WebviewLoader implements vscode.Disposable { ) { const viewColumn = vscode.ViewColumn.One; this.githubToken = githubToken; + this.gitPath = '' + this._panel = vscode.window.createWebviewPanel("WebviewLoader", "githru-view", viewColumn, { enableScripts: true, @@ -44,6 +46,7 @@ export default class WebviewLoader implements vscode.Disposable { this._panel.webview.onDidReceiveMessage(async (message: { command: string; payload?: string }) => { const { command, payload } = message; + await this.setGitPath() if (command === "fetchAnalyzedData" || command === "refresh") { const baseBranchName = (payload && JSON.parse(payload)) ?? (await this.fetchCurrentBranch()); @@ -105,13 +108,13 @@ export default class WebviewLoader implements vscode.Disposable { return normalizeFsPath(currentWorkspaceUri.fsPath); } - private async getGitPath() { - return (await findGit()).path; + private async setGitPath() { + this.gitPath = (await findGit()).path } - + private async fetchBranches() { try { - return await getBranches(await this.getGitPath(), this.getCurrentWorkspacePath()); + return await getBranches(this.gitPath, this.getCurrentWorkspacePath()); } catch (e) { console.debug(e); } @@ -120,7 +123,8 @@ export default class WebviewLoader implements vscode.Disposable { private async fetchCurrentBranch() { let branchName; try { - branchName = await getCurrentBranchName(await this.getGitPath(), this.getCurrentWorkspacePath()); + console.log('이거다',this.gitPath) + branchName = await getCurrentBranchName(this.gitPath, this.getCurrentWorkspacePath()); } catch (error) { console.error(error); } @@ -141,8 +145,8 @@ export default class WebviewLoader implements vscode.Disposable { if (!baseBranchName) { baseBranchName = await this.fetchCurrentBranch(); } - const gitLog = await getGitLog(await this.getGitPath(), this.getCurrentWorkspacePath()); - const gitConfig = await getGitConfig(await this.getGitPath(), this.getCurrentWorkspacePath(), "origin"); + const gitLog = await getGitLog(this.gitPath, this.getCurrentWorkspacePath()); + const gitConfig = await getGitConfig(this.gitPath, this.getCurrentWorkspacePath(), "origin"); const { owner, repo } = getRepo(gitConfig); const engine = new AnalysisEngine({ isDebugMode: true,