Enhance repository cloning logic in install script
- Updated the install script to attempt cloning via SSH first for private repositories, falling back to HTTPS if the SSH method fails. - Added detailed error handling and user guidance for SSH key setup, improving the installation experience for users with private repositories.
This commit is contained in:
parent
aa6394e94f
commit
69a338610a
1 changed files with 20 additions and 1 deletions
|
|
@ -148,7 +148,26 @@ function Install-Repository {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
git clone --branch $Branch $RepoUrl $InstallDir
|
# Try SSH first (for private repo access), fall back to HTTPS
|
||||||
|
Write-Info "Trying SSH clone..."
|
||||||
|
$sshResult = git clone --branch $Branch $RepoUrlSsh $InstallDir 2>&1
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Write-Success "Cloned via SSH"
|
||||||
|
} else {
|
||||||
|
Write-Info "SSH failed, trying HTTPS..."
|
||||||
|
$httpsResult = git clone --branch $Branch $RepoUrlHttps $InstallDir 2>&1
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Write-Success "Cloned via HTTPS"
|
||||||
|
} else {
|
||||||
|
Write-Error "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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Success "Repository ready"
|
Write-Success "Repository ready"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue