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:
parent
21a59a4a7c
commit
cd66546e24
1 changed files with 11 additions and 7 deletions
|
|
@ -394,13 +394,20 @@ function Install-Repository {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
} else {
|
} 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..."
|
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
|
$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"
|
Write-Success "Cloned via SSH"
|
||||||
} else {
|
} 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..."
|
Write-Info "SSH failed, trying HTTPS..."
|
||||||
$httpsResult = git clone --branch $Branch --recurse-submodules $RepoUrlHttps $InstallDir 2>&1
|
$httpsResult = git clone --branch $Branch --recurse-submodules $RepoUrlHttps $InstallDir 2>&1
|
||||||
|
|
||||||
|
|
@ -408,9 +415,6 @@ function Install-Repository {
|
||||||
Write-Success "Cloned via HTTPS"
|
Write-Success "Cloned via HTTPS"
|
||||||
} else {
|
} else {
|
||||||
Write-Err "Failed to clone repository"
|
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
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -731,8 +735,8 @@ function Write-Completion {
|
||||||
Write-Host "View/edit configuration"
|
Write-Host "View/edit configuration"
|
||||||
Write-Host " hermes config edit " -NoNewline -ForegroundColor Green
|
Write-Host " hermes config edit " -NoNewline -ForegroundColor Green
|
||||||
Write-Host "Open config in editor"
|
Write-Host "Open config in editor"
|
||||||
Write-Host " hermes gateway install " -NoNewline -ForegroundColor Green
|
Write-Host " hermes gateway " -NoNewline -ForegroundColor Green
|
||||||
Write-Host "Install gateway service (messaging + cron)"
|
Write-Host "Start messaging gateway (Telegram, Discord, etc.)"
|
||||||
Write-Host " hermes update " -NoNewline -ForegroundColor Green
|
Write-Host " hermes update " -NoNewline -ForegroundColor Green
|
||||||
Write-Host "Update to latest version"
|
Write-Host "Update to latest version"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue