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.
This commit is contained in:
xxxigm 2026-06-30 20:11:01 +07:00
parent 824f2279da
commit a40f22798e
2 changed files with 17 additions and 2 deletions

View file

@ -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) {