refactor: improve SSH cloning process in install script
- Added GIT_SSH_COMMAND to disable interactive prompts and set a timeout for SSH cloning, enhancing the cloning process for private repositories. - Implemented cleanup of partial SSH clones if the SSH attempt fails, ensuring a smoother fallback to HTTPS cloning.
This commit is contained in:
parent
b5dbf8e43d
commit
21a59a4a7c
1 changed files with 5 additions and 4 deletions
|
|
@ -539,18 +539,19 @@ clone_repo() {
|
||||||
else
|
else
|
||||||
# Try SSH first (for private repo access), fall back to HTTPS
|
# Try SSH first (for private repo access), fall back to HTTPS
|
||||||
# Use --recurse-submodules to also clone mini-swe-agent and tinker-atropos
|
# Use --recurse-submodules to also clone mini-swe-agent and tinker-atropos
|
||||||
|
# GIT_SSH_COMMAND disables interactive prompts and sets a short timeout
|
||||||
|
# so SSH fails fast instead of hanging when no key is configured.
|
||||||
log_info "Trying SSH clone..."
|
log_info "Trying SSH clone..."
|
||||||
if git clone --branch "$BRANCH" --recurse-submodules "$REPO_URL_SSH" "$INSTALL_DIR" 2>/dev/null; then
|
if GIT_SSH_COMMAND="ssh -o BatchMode=yes -o ConnectTimeout=5" \
|
||||||
|
git clone --branch "$BRANCH" --recurse-submodules "$REPO_URL_SSH" "$INSTALL_DIR" 2>/dev/null; then
|
||||||
log_success "Cloned via SSH"
|
log_success "Cloned via SSH"
|
||||||
else
|
else
|
||||||
|
rm -rf "$INSTALL_DIR" 2>/dev/null # Clean up partial SSH clone
|
||||||
log_info "SSH failed, trying HTTPS..."
|
log_info "SSH failed, trying HTTPS..."
|
||||||
if git clone --branch "$BRANCH" --recurse-submodules "$REPO_URL_HTTPS" "$INSTALL_DIR"; then
|
if git clone --branch "$BRANCH" --recurse-submodules "$REPO_URL_HTTPS" "$INSTALL_DIR"; then
|
||||||
log_success "Cloned via HTTPS"
|
log_success "Cloned via HTTPS"
|
||||||
else
|
else
|
||||||
log_error "Failed to clone repository"
|
log_error "Failed to clone repository"
|
||||||
log_info "For private repo access, ensure your SSH key is added to GitHub:"
|
|
||||||
log_info " ssh-add ~/.ssh/id_rsa"
|
|
||||||
log_info " ssh -T git@github.com # Test connection"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue