| ... | @@ -1,4 +1,4 @@ | ... | @@ -1,4 +1,4 @@ |
| 1 | import { execFileSync, spawn, type ChildProcess } from "node:child_process"; | 1 | import { spawn, type ChildProcess } from "node:child_process"; |
| 2 | import { randomBytes } from "node:crypto"; | 2 | import { randomBytes } from "node:crypto"; |
| 3 | import fs from "node:fs"; | 3 | import fs from "node:fs"; |
| 4 | import net from "node:net"; | 4 | import net from "node:net"; |
| ... | @@ -110,28 +110,13 @@ function resolveEmbeddedCommitHash(): string | null { | ... | @@ -110,28 +110,13 @@ function resolveEmbeddedCommitHash(): string | null { |
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | | 112 | |
| 113 | function resolveGitCommitHash(): string | null { | | |
| 114 | try { | | |
| 115 | const stdout = execFileSync("git", ["rev-parse", `--short=${COMMIT_HASH_DISPLAY_LENGTH}`, "HEAD"], { | | |
| 116 | cwd: ROOT_DIR, | | |
| 117 | encoding: "utf8", | | |
| 118 | stdio: ["ignore", "pipe", "ignore"], | | |
| 119 | }); | | |
| 120 | return normalizeCommitHash(stdout); | | |
| 121 | } catch { | | |
| 122 | return null; | | |
| 123 | } | | |
| 124 | } | | |
| 125 | | | |
| 126 | function resolveAboutCommitHash(): string | null { | 113 | function resolveAboutCommitHash(): string | null { |
| 127 | if (aboutCommitHashCache !== undefined) { | 114 | if (aboutCommitHashCache !== undefined) { |
| 128 | return aboutCommitHashCache; | 115 | return aboutCommitHashCache; |
| 129 | } | 116 | } |
| 130 | | 117 | |
| 131 | aboutCommitHashCache = | 118 | aboutCommitHashCache = |
| 132 | normalizeCommitHash(process.env.T3CODE_COMMIT_HASH) ?? | 119 | normalizeCommitHash(process.env.T3CODE_COMMIT_HASH) ?? resolveEmbeddedCommitHash(); |
| 133 | resolveEmbeddedCommitHash() ?? | | |
| 134 | resolveGitCommitHash(); | | |
| 135 | | 120 | |
| 136 | return aboutCommitHashCache; | 121 | return aboutCommitHashCache; |
| 137 | } | 122 | } |
| ... | @@ -483,11 +468,7 @@ function registerIpcHandlers(): void { | ... | @@ -483,11 +468,7 @@ function registerIpcHandlers(): void { |
| 483 | ipcMain.removeHandler(CONTEXT_MENU_CHANNEL); | 468 | ipcMain.removeHandler(CONTEXT_MENU_CHANNEL); |
| 484 | ipcMain.handle( | 469 | ipcMain.handle( |
| 485 | CONTEXT_MENU_CHANNEL, | 470 | CONTEXT_MENU_CHANNEL, |
| 486 | async ( | 471 | async (_event, items: ContextMenuItem[], position?: { x: number; y: number }) => { |
| 487 | _event, | | |
| 488 | items: ContextMenuItem[], | | |
| 489 | position?: { x: number; y: number }, | | |
| 490 | ) => { | | |
| 491 | const normalizedItems = items | 472 | const normalizedItems = items |
| 492 | .filter((item) => typeof item.id === "string" && typeof item.label === "string") | 473 | .filter((item) => typeof item.id === "string" && typeof item.label === "string") |
| 493 | .map((item) => ({ | 474 | .map((item) => ({ |
| ... | @@ -538,7 +519,7 @@ function registerIpcHandlers(): void { | ... | @@ -538,7 +519,7 @@ function registerIpcHandlers(): void { |
| 538 | const menu = Menu.buildFromTemplate(template); | 519 | const menu = Menu.buildFromTemplate(template); |
| 539 | menu.popup({ | 520 | menu.popup({ |
| 540 | window, | 521 | window, |
| 541 | ...(popupPosition ?? {}), | 522 | ...popupPosition, |
| 542 | callback: () => resolve(null), | 523 | callback: () => resolve(null), |
| 543 | }); | 524 | }); |
| 544 | }); | 525 | }); |