fix(desktop): branch-pin the CLI manual-update command card
The 'Update from your terminal' card (shown to CLI installs with no staged updater) hardcoded bare `hermes update` — which defaults to main and would switch a bb/gui (or any non-main) checkout off-branch. Same bug we fixed for the GUI button, leaked into the card's copy text. Resolve the checkout's current branch and show `hermes update --branch <current>` for non-main checkouts; keep it bare for main so the card stays clean. Best-effort: bare fallback if branch detection fails. Matches the GUI button + installer --update contract; bare terminal/bot/TUI update paths still default to main, unchanged.
This commit is contained in:
@@ -1065,14 +1065,22 @@ async function applyUpdates(opts = {}) {
|
|||||||
// `hermes desktop`, never the Tauri installer that self-copies
|
// `hermes desktop`, never the Tauri installer that self-copies
|
||||||
// hermes-setup.exe into HERMES_HOME). They DO have a working `hermes`
|
// hermes-setup.exe into HERMES_HOME). They DO have a working `hermes`
|
||||||
// on PATH / in the venv, so the correct path is the one-liner in their
|
// on PATH / in the venv, so the correct path is the one-liner in their
|
||||||
// native medium: `hermes update`. We surface that as an intentional
|
// native medium. We show the EXACT command, branch-pinned to the
|
||||||
// "manual update" outcome — NOT an error with a dead retry button.
|
// checkout they're on — bare `hermes update` defaults to main and would
|
||||||
//
|
// silently switch a bb/gui (or any non-main) install off-branch. Mirror
|
||||||
// We resolve the most copy-pasteable command we can: prefer the bare
|
// the GUI button's contract: append --branch <current> for non-main
|
||||||
// `hermes update` (works if hermes is on PATH, which install.sh/ps1
|
// checkouts, keep it bare for main so the card stays clean.
|
||||||
// both arrange), and include the resolved checkout dir as context.
|
|
||||||
const command = 'hermes update'
|
|
||||||
const updateRoot = resolveUpdateRoot()
|
const updateRoot = resolveUpdateRoot()
|
||||||
|
let command = 'hermes update'
|
||||||
|
try {
|
||||||
|
const head = await runGit(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: updateRoot })
|
||||||
|
const branch = (head.stdout || '').trim()
|
||||||
|
if (head.code === 0 && branch && branch !== 'HEAD' && branch !== 'main') {
|
||||||
|
command = `hermes update --branch ${branch}`
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Best-effort: fall back to bare `hermes update` if branch detection fails.
|
||||||
|
}
|
||||||
rememberLog(`[updates] no staged updater; surfacing manual \`${command}\` for CLI install at ${updateRoot}`)
|
rememberLog(`[updates] no staged updater; surfacing manual \`${command}\` for CLI install at ${updateRoot}`)
|
||||||
emitUpdateProgress({ stage: 'manual', message: command, percent: null })
|
emitUpdateProgress({ stage: 'manual', message: command, percent: null })
|
||||||
return { ok: true, manual: true, command, hermesRoot: updateRoot }
|
return { ok: true, manual: true, command, hermesRoot: updateRoot }
|
||||||
|
|||||||
Reference in New Issue
Block a user