refactor: enhance install script output and command handling

- Updated the SSH cloning process to include a cleanup step for partial clones if the SSH attempt fails, improving the fallback to HTTPS.
- Modified output messages for clarity, including renaming the gateway installation command to better reflect its function.
This commit is contained in:
teknium1 2026-02-25 13:47:04 -08:00
parent 21a59a4a7c
commit cd66546e24

View file

@ -394,13 +394,20 @@ function Install-Repository {
exit 1
}
} else {
# Try SSH first (for private repo access), fall back to HTTPS
# Try SSH first (for private repo access), fall back to HTTPS.
# GIT_SSH_COMMAND with BatchMode=yes prevents SSH from hanging
# when no key is configured (fails immediately instead of prompting).
Write-Info "Trying SSH clone..."
$env:GIT_SSH_COMMAND = "ssh -o BatchMode=yes -o ConnectTimeout=5"
$sshResult = git clone --branch $Branch --recurse-submodules $RepoUrlSsh $InstallDir 2>&1
$sshExitCode = $LASTEXITCODE
$env:GIT_SSH_COMMAND = $null
if ($LASTEXITCODE -eq 0) {
if ($sshExitCode -eq 0) {
Write-Success "Cloned via SSH"
} else {
# Clean up partial SSH clone before retrying
if (Test-Path $InstallDir) { Remove-Item -Recurse -Force $InstallDir -ErrorAction SilentlyContinue }
Write-Info "SSH failed, trying HTTPS..."
$httpsResult = git clone --branch $Branch --recurse-submodules $RepoUrlHttps $InstallDir 2>&1
@ -408,9 +415,6 @@ function Install-Repository {
Write-Success "Cloned via HTTPS"
} else {
Write-Err "Failed to clone repository"
Write-Info "For private repo access, ensure your SSH key is added to GitHub:"
Write-Info " ssh-add ~/.ssh/id_rsa"
Write-Info " ssh -T git@github.com # Test connection"
exit 1
}
}
@ -731,8 +735,8 @@ function Write-Completion {
Write-Host "View/edit configuration"
Write-Host " hermes config edit " -NoNewline -ForegroundColor Green
Write-Host "Open config in editor"
Write-Host " hermes gateway install " -NoNewline -ForegroundColor Green
Write-Host "Install gateway service (messaging + cron)"
Write-Host " hermes gateway " -NoNewline -ForegroundColor Green
Write-Host "Start messaging gateway (Telegram, Discord, etc.)"
Write-Host " hermes update " -NoNewline -ForegroundColor Green
Write-Host "Update to latest version"
Write-Host ""