From a40f22798ec6b5877958f6dbe5aeda8468e7d628 Mon Sep 17 00:00:00 2001 From: xxxigm Date: Tue, 30 Jun 2026 20:11:01 +0700 Subject: [PATCH] fix(installer): reset managed clone when ff-only pull fails Bootstrap and desktop updates run install.ps1/install.sh, which aborted with exit 128 when the managed checkout had diverged from origin/main. Mirror the hermes update recovery path: reset to origin/$BRANCH instead of failing the repository stage. --- scripts/install.ps1 | 10 +++++++++- scripts/install.sh | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index fde9d4363..15f98f4b4 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -1362,8 +1362,16 @@ function Install-Repository { } else { git -c windows.appendAtomically=false checkout $Branch if ($LASTEXITCODE -ne 0) { throw "git checkout $Branch failed (exit $LASTEXITCODE)" } + # Managed installs should follow origin/$Branch exactly. If + # the checkout has diverged (or has local-only commits), + # ff-only pull cannot succeed — mirror ``hermes update`` and + # reset to the fetched remote so bootstrap/install can recover. git -c windows.appendAtomically=false pull --ff-only origin $Branch - if ($LASTEXITCODE -ne 0) { throw "git pull failed (exit $LASTEXITCODE)" } + if ($LASTEXITCODE -ne 0) { + Write-Warn "Fast-forward not possible; resetting managed install to origin/$Branch..." + git -c windows.appendAtomically=false reset --hard "origin/$Branch" + if ($LASTEXITCODE -ne 0) { throw "git reset --hard origin/$Branch failed (exit $LASTEXITCODE)" } + } } if ($autostashRef) { diff --git a/scripts/install.sh b/scripts/install.sh index 864f9e075..4171ba3d7 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1222,7 +1222,14 @@ clone_repo() { git remote set-branches origin "$BRANCH" 2>/dev/null || true git fetch origin "$BRANCH" git checkout "$BRANCH" - git pull --ff-only origin "$BRANCH" + # Managed installs should follow origin/$BRANCH exactly. If the + # checkout has diverged (or has local-only commits), ff-only pull + # cannot succeed — mirror ``hermes update`` and reset to the + # fetched remote so bootstrap/install can recover. + if ! git pull --ff-only origin "$BRANCH"; then + log_warn "Fast-forward not possible; resetting managed install to origin/$BRANCH..." + git reset --hard "origin/$BRANCH" + fi if [ -n "$autostash_ref" ]; then local restore_now="yes"