The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): resolve PM-managed Git for source checks
Yuan Li0f0c6283042a
diff --git a/apps/desktop/electron/git-binary-candidates.test.ts b/apps/desktop/electron/git-binary-candidates.test.tsindex da1c00b9952..8dab355f7d9 100644--- a/apps/desktop/electron/git-binary-candidates.test.ts+++ b/apps/desktop/electron/git-binary-candidates.test.ts@@ -3,7 +3,7 @@ import path from 'node:path'import { describe, test } from 'vitest'-import { type GitCandidateFs, ugitGitBinaries, windowsGitCandidates } from './git-binary-candidates'+import { type GitCandidateFs, managedGitBinaries, ugitGitBinaries, windowsGitCandidates } from './git-binary-candidates'const LAD = path.join('C:', 'Users', 'suceru', 'AppData', 'Local')@@ -55,6 +55,18 @@ describe('ugitGitBinaries (#61494)', () => {})})+describe('managedGitBinaries', () => {+ test('finds the newest PM-managed Git under Hermes tools', () => {+ const managed = path.join(LAD, 'hermes', 'tools', 'git-2.53.0+3-win32-x64', 'cmd', 'git.exe')+ const fs = fakeFs(+ { [path.join(LAD, 'hermes', 'tools')]: ['git-2.52.0+2-win32-x64', 'git-2.53.0+3-win32-x64'] },+ [managed]+ )++ assert.deepEqual(managedGitBinaries(LAD, fs), [managed])+ })+})+describe('windowsGitCandidates (#61494)', () => {const env = {localAppData: LAD,diff --git a/apps/desktop/electron/git-binary-candidates.ts b/apps/desktop/electron/git-binary-candidates.tsindex b7823621735..bfaccd45910 100644--- a/apps/desktop/electron/git-binary-candidates.ts+++ b/apps/desktop/electron/git-binary-candidates.ts@@ -19,6 +19,9 @@ const UGIT_DIR = 'UGit'const UGIT_APP_PREFIX = 'app-'/** Where the UGit-bundled Git-for-Windows puts git.exe inside an app dir. */const UGIT_GIT_REL = path.join('resources', 'app', 'git', 'cmd', 'git.exe')+/** PM-managed Git tool directories under the Hermes local application root. */+const HERMES_TOOLS_DIR = path.join('hermes', 'tools')+const MANAGED_GIT_PREFIX = 'git-'/*** Every `%LOCALAPPDATA%\UGit\app-*\resources\app\git\cmd\git.exe` on disk,@@ -52,6 +55,30 @@ export function ugitGitBinaries(localAppData: string, fs: GitCandidateFs): strin.filter(fs.existsSync)}++/**+ * Find Git installed by Hermes PM under `%LOCALAPPDATA%\hermes\tools`.+ * PM versions the tool directory, so resolve the newest available executable+ * rather than assuming a particular Git release.+ */+export function managedGitBinaries(localAppData: string, fs: GitCandidateFs): string[] {+ const toolsRoot = path.join(localAppData, HERMES_TOOLS_DIR)++ let entries: string[]++ try {+ entries = fs.readdirSync(toolsRoot)+ } catch {+ return []+ }++ return entries+ .filter(entry => entry.startsWith(MANAGED_GIT_PREFIX))+ .sort((a, b) => b.localeCompare(a, undefined, { numeric: true }))+ .map(entry => path.join(toolsRoot, entry, 'cmd', 'git.exe'))+ .filter(fs.existsSync)+}+/*** resolveGitBinary's fixed Windows candidate list, in preference order:* the Hermes-bundled PortableGit first, then UGit's bundled copies, then the@@ -61,6 +88,7 @@ export function windowsGitCandidates(env: WindowsGitEnv, fs: GitCandidateFs): stconst candidates: string[] = []if (env.localAppData) {+ candidates.push(...managedGitBinaries(env.localAppData, fs))candidates.push(path.join(env.localAppData, 'hermes', 'git', 'cmd', 'git.exe'))candidates.push(path.join(env.localAppData, 'hermes', 'git', 'bin', 'git.exe'))candidates.push(...ugitGitBinaries(env.localAppData, fs))