From 512fca6213fa300a05cc8d0f0641258058ad7df7 Mon Sep 17 00:00:00 2001 From: KellyMichels Date: Thu, 23 Jul 2026 18:51:05 -0500 Subject: [PATCH] fix(zstart): git-pull pre-step can't hang on a credential prompt start.gitPull ran `git pull --ff-only` before starting the server; in an environment with no cached git credentials (e.g. WSL against an HTTPS GitHub remote) git prompted "Username for 'https://github.com':" and the whole start blocked on stdin. Run the pull with GIT_TERMINAL_PROMPT=0 so it fails fast, log a clear "auto-pull skipped" note, and start with the current checkout. Bash + PowerShell. --- bash/zstart | 10 ++++++---- zstart.ps1 | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bash/zstart b/bash/zstart index 7780e87..a3b540b 100644 --- a/bash/zstart +++ b/bash/zstart @@ -66,10 +66,12 @@ start_prep() { # dim " env $name=$val" done < <(jq -r --arg k "$key" '.projects[$k].start.env // {} | to_entries[] | "\(.key)\t\(.value)"' "$ZCONFIG") if [ "$(zproj "$key" .start.gitPull)" = "true" ] && [ -d "$root/.git" ]; then - local last - last="$( (cd "$root" && git pull --ff-only 2>&1) | tail -1 )" - dim " git pull: $last" - (cd "$root" && git rev-parse HEAD >/dev/null 2>&1) || warn " Auto-pull failed - run 'git pull' manually if needed." + # GIT_TERMINAL_PROMPT=0 so a repo that needs credentials fails fast instead + # of blocking the server start on an interactive "Username for ..." prompt. + local out rc + out="$( (cd "$root" && GIT_TERMINAL_PROMPT=0 git pull --ff-only 2>&1) )"; rc=$? + dim " git pull: $(printf '%s\n' "$out" | tail -1)" + [ "$rc" -eq 0 ] || warn " Auto-pull skipped (exit $rc) - starting with the current checkout. (git needs credentials here, or set start.gitPull=false)" fi } diff --git a/zstart.ps1 b/zstart.ps1 index eaada37..363d23d 100644 --- a/zstart.ps1 +++ b/zstart.ps1 @@ -199,14 +199,18 @@ function Invoke-ProjectStartPrep { } if ($Proj.start.gitPull -and (Test-Path (Join-Path $Proj.localRoot ".git"))) { Push-Location -LiteralPath $Proj.localRoot + # GIT_TERMINAL_PROMPT=0 so a repo that needs credentials fails fast + # instead of blocking the server start on a "Username for ..." prompt. + $prev = $env:GIT_TERMINAL_PROMPT; $env:GIT_TERMINAL_PROMPT = "0" try { $pullOut = git pull --ff-only 2>&1 $last = ($pullOut | Select-Object -Last 1) Write-Host " git pull: $last" -ForegroundColor DarkGray if ($LASTEXITCODE -ne 0) { - Write-Host " Auto-pull failed - run 'git pull' manually if needed." -ForegroundColor Yellow + Write-Host " Auto-pull skipped - starting with the current checkout. (git needs credentials here, or set start.gitPull=false)" -ForegroundColor Yellow } } finally { + $env:GIT_TERMINAL_PROMPT = $prev Pop-Location } }