From b780a4646d94e3c07f300fde505480d109c27ab1 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Fri, 29 Nov 2024 02:02:12 +0000 Subject: [PATCH] chore: remove unused fn --- static/scripts/config-parser.ts | 69 --------------------------------- 1 file changed, 69 deletions(-) diff --git a/static/scripts/config-parser.ts b/static/scripts/config-parser.ts index a02b21c..e695375 100644 --- a/static/scripts/config-parser.ts +++ b/static/scripts/config-parser.ts @@ -202,73 +202,4 @@ export class ConfigParser { this.newConfigYml = YAML.stringify({ plugins: [] }); this.saveConfig(); } - - async handleMissingStorageBranchOrFile(octokit: Octokit, owner: string, repo: string | null) { - let mostRecentDefaultHeadCommitSha; - - try { - const { data: defaultBranchData } = await octokit.rest.repos.getCommit({ - owner, - repo: repo ? repo : UBIQUITY_OS, - ref: repo ? "development" : "main", - }); - mostRecentDefaultHeadCommitSha = defaultBranchData.sha; - } catch (er) { - throw new Error(`Failed to get default branch commit sha:\n ${String(er)}`); - } - - // Check if the branch exists - try { - await octokit.rest.repos.getBranch({ - owner, - repo: repo ? repo : UBIQUITY_OS, - branch: repo ? "development" : "main", - }); - } catch (branchError) { - if (branchError instanceof RequestError || branchError instanceof Error) { - const { message } = branchError; - if (message.toLowerCase().includes(`branch not found`)) { - // Branch doesn't exist, create the branch - try { - await octokit.rest.git.createRef({ - owner, - repo: repo ? repo : UBIQUITY_OS, - ref: `refs/heads/${repo ? "development" : "main"}`, - sha: mostRecentDefaultHeadCommitSha, - }); - } catch (err) { - throw new Error(`Failed to create branch:\n ${String(err)}`); - } - } else { - throw new Error(`Failed to handle missing storage branch or file:\n ${String(branchError)}`); - } - } else { - throw new Error(`Failed to handle missing storage branch or file:\n ${String(branchError)}`); - } - } - - try { - // Create or update the file - await octokit.rest.repos.createOrUpdateFileContents({ - owner, - repo: repo ? repo : UBIQUITY_OS, - path: CONFIG_PATH, - branch: repo ? "development" : "main", - message: `chore: create ${CONFIG_PATH.replace(/([A-Z])/g, " $1").toLowerCase()}`, - content: btoa("{\n}"), - sha: mostRecentDefaultHeadCommitSha, - }); - } catch (err) { - throw new Error(`Failed to create new config file:\n ${String(err)}`); - } - - const config = localStorage.getItem("selectedConfig"); - - const msgParts = ["Created an empty", config, "config in", repo ? repo : `your org: ${owner}`]; - - toastNotification(msgParts.join(" "), { - type: "success", - actionText: "Continue", - }); - } }