diff --git a/tests/install/installer-script-e2e.sh b/tests/install/installer-script-e2e.sh index 77be0c0f6e..ec5e553c70 100755 --- a/tests/install/installer-script-e2e.sh +++ b/tests/install/installer-script-e2e.sh @@ -122,18 +122,67 @@ git -C "$SERVE_REPO" symbolic-ref HEAD refs/heads/main git -C "$SERVE_REPO" config uploadpack.allowAnySHA1InWant true ok "serve.git main = $OLD_SHA ($INSTALL_REF), update target $HEAD_SHA" -# --- the git URL redirect ----------------------------------------------------- - -# A driver-owned global gitconfig, NOT GIT_CONFIG_COUNT/KEY_n/VALUE_n env -# config: install.sh sets those itself and would clobber ours. -GIT_CFG="$WORK_ROOT/gitconfig" -cat > "$GIT_CFG" < "$GIT_CFG" < "$SHIM_DIR/git" < $REAL_GIT (origin reports $REPO_URL_HTTPS)" +} + +# later, we might factor this out into a separate step like the macos desktop one. +arm_redirect # Isolated HOME: the runner's real one may carry a preinstalled hermes or a # developer config, and old installer scripts hardcode $HOME/.hermes (the @@ -144,10 +193,6 @@ mkdir -p "$HOME/.local/bin" export PATH="$HOME/.local/bin:$PATH" export HERMES_HOME="$HOME/.hermes" mkdir -p "$HERMES_HOME" -# serve.git's file:// origin looks like a fork to the updater, whose "add the -# official repo as upstream?" prompt would hang a headless run. This marker is -# the product's own mechanism for suppressing it. -touch "$HERMES_HOME/.skip_upstream_prompt" INSTALL_DIR="$HERMES_HOME/hermes-agent" diff --git a/tests/install/macos-desktop-e2e.sh b/tests/install/macos-desktop-e2e.sh index 51418a8f5d..f52867bc61 100755 --- a/tests/install/macos-desktop-e2e.sh +++ b/tests/install/macos-desktop-e2e.sh @@ -84,8 +84,65 @@ log_group() { # Every phase runs in its own process (separate CI steps), so the redirect # env is re-established here, not inherited. arm_redirect() { + # --- the git URL redirect ----------------------------------------------------- + + # we redirect to our own repo so we can play around with what commit hermes thinks we're on. + # A driver-owned global gitconfig, NOT GIT_CONFIG_COUNT/KEY_n/VALUE_n env + # config: install.sh sets those itself and would clobber ours. + actual_git_url="$(git -C "$REPO_ROOT" remote get-url origin)" GIT_CFG="$WORK_ROOT/gitconfig" + cat > "$GIT_CFG" < "$SHIM_DIR/git" < $REAL_GIT (origin reports $REPO_URL_HTTPS)" + + # ------- export HOME="$HOME_SANDBOX" export PATH="$HOME/.local/bin:$PATH" export HERMES_HOME="$HOME/.hermes" @@ -115,11 +172,6 @@ phase_stage() { git -C "$SERVE_REPO" symbolic-ref HEAD refs/heads/main git -C "$SERVE_REPO" config uploadpack.allowAnySHA1InWant true - cat > "$WORK_ROOT/gitconfig" < $fileUrl" + + + # shim git and make 'git remote get-url origin' report the actual HA upstream + + # insteadOf is transparent for transport but `git remote get-url origin` gives you the + # replacement, so _get_origin_url() sees file://$SERVE_REPO and _is_fork() would return true. + # we check for the arguments "remote get-url origin" in order in any position + # to allow for e.g. -c with some config being passed. + # if we didn't do this, we'd need the .skip_upstream_prompt file to prevent a hang in headless,"add the + # official repo as upstream?" prompt would hang a headless run. But we don't anymore :D + + $realGit = (Get-Command git.exe -ErrorAction Stop).Source + $shimDir = Join-Path $WorkRoot "shim" + New-Item -ItemType Directory -Path $shimDir -Force | Out-Null + $shimPath = Join-Path $shimDir "git.bat" + @" +@echo off +setlocal enabledelayedexpansion +set prev2= +set prev1= +:loop +if "%~1"=="" goto passthrough +if /I "!prev2!"=="remote" if /I "!prev1!"=="get-url" if /I "%~1"=="origin" ( + echo $RepoUrlHttps + exit /b 0 +) +set prev2=!prev1! +set prev1=%~1 +shift +goto loop +:passthrough +`"$realGit`" %* +exit /b %ERRORLEVEL% +"@ | Set-Content -LiteralPath $shimPath -Encoding ASCII + + $env:PATH = "$shimDir;$env:PATH" + + # check it worked + $observedGitUrl = Invoke-Git @("-C", $RepoRoot, "remote", "get-url", "origin") + Assert-True ($observedGitUrl -eq $RepoUrlHttps) "git remote get-url shim: origin resolves to '$observedGitUrl', expected '$RepoUrlHttps'" + Write-Host " git remote get-url shim: $shimPath -> $realGit" + Write-Host " 'remote get-url origin' now reports $RepoUrlHttps" } function Read-State { @@ -586,19 +631,6 @@ function Invoke-PhaseInstallGui { Add-Content -LiteralPath $envFile -Value "OPENROUTER_API_KEY=sk-or-...-key" } Write-Host " seeded placeholder provider key for the update leg" - - # Suppress the interactive "add upstream remote?" prompt during the GUI - # update leg. Our serve.git origin (file://) looks like a fork to - # `hermes update`, so `_sync_with_upstream_if_needed` would call bare - # input() -- which HANGS FOREVER when the Desktop spawns the hand-off via - # `cmd start /min` (a real but empty console; input() blocks waiting for a - # keystroke that never comes). Real GUI users on the official github - # origin never hit this path (_is_fork is false). The skip marker - # (.skip_upstream_prompt in HERMES_HOME) is the product's own mechanism - # for "don't ask about upstream", so setting it keeps the update flow - # faithful while avoiding the fork-only prompt. - New-Item -ItemType File -Path (Join-Path $HermesHome ".skip_upstream_prompt") -Force | Out-Null - Write-Host " set .skip_upstream_prompt (serve.git origin looks like a fork; avoids the fork-only input() hang)" } # ---------------------------------------------------------------------------- @@ -777,7 +809,6 @@ function Invoke-PhaseInstall { # product's own suppression mechanism. $env:HERMES_HOME = $HermesHome New-Item -ItemType Directory -Path $HermesHome -Force | Out-Null - New-Item -ItemType File -Path (Join-Path $HermesHome ".skip_upstream_prompt") -Force | Out-Null switch ($InstallMethod) { "desktop-installer@latest" { Invoke-PhaseInstallGui