mirror of
https://github.com/kellymichels/zscripts-token-savers
synced 2026-10-07 07:18:18 +00:00
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.
This commit is contained in:
parent
e64829f97c
commit
512fca6213
10
bash/zstart
10
bash/zstart
@ -66,10 +66,12 @@ start_prep() { # <key>
|
|||||||
dim " env $name=$val"
|
dim " env $name=$val"
|
||||||
done < <(jq -r --arg k "$key" '.projects[$k].start.env // {} | to_entries[] | "\(.key)\t\(.value)"' "$ZCONFIG")
|
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
|
if [ "$(zproj "$key" .start.gitPull)" = "true" ] && [ -d "$root/.git" ]; then
|
||||||
local last
|
# GIT_TERMINAL_PROMPT=0 so a repo that needs credentials fails fast instead
|
||||||
last="$( (cd "$root" && git pull --ff-only 2>&1) | tail -1 )"
|
# of blocking the server start on an interactive "Username for ..." prompt.
|
||||||
dim " git pull: $last"
|
local out rc
|
||||||
(cd "$root" && git rev-parse HEAD >/dev/null 2>&1) || warn " Auto-pull failed - run 'git pull' manually if needed."
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -199,14 +199,18 @@ function Invoke-ProjectStartPrep {
|
|||||||
}
|
}
|
||||||
if ($Proj.start.gitPull -and (Test-Path (Join-Path $Proj.localRoot ".git"))) {
|
if ($Proj.start.gitPull -and (Test-Path (Join-Path $Proj.localRoot ".git"))) {
|
||||||
Push-Location -LiteralPath $Proj.localRoot
|
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 {
|
try {
|
||||||
$pullOut = git pull --ff-only 2>&1
|
$pullOut = git pull --ff-only 2>&1
|
||||||
$last = ($pullOut | Select-Object -Last 1)
|
$last = ($pullOut | Select-Object -Last 1)
|
||||||
Write-Host " git pull: $last" -ForegroundColor DarkGray
|
Write-Host " git pull: $last" -ForegroundColor DarkGray
|
||||||
if ($LASTEXITCODE -ne 0) {
|
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 {
|
} finally {
|
||||||
|
$env:GIT_TERMINAL_PROMPT = $prev
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user