mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
fix: git clone pre-check
This commit is contained in:
@@ -898,7 +898,7 @@ FAQs: <https://github.com/zhayujie/CowAgent/wiki/FAQs>
|
||||
|
||||
# 📌 项目更名说明
|
||||
|
||||
本项目原名 `chatgpt-on-wechat`(GitHub 原地址:https://github.com/zhayujie/chatgpt-on-wechat),
|
||||
本项目原名 `chatgpt-on-wechat`(GitHub 原地址:https://github.com/zhayujie/chatgpt-on-wechat ),
|
||||
于 2026.04.13 正式更名为 **CowAgent**。GitHub 已自动设置重定向,原有链接仍可正常访问。
|
||||
|
||||
如需更新本地仓库的远程地址(可选):
|
||||
|
||||
17
run.sh
17
run.sh
@@ -171,12 +171,17 @@ clone_project() {
|
||||
mv CowAgent-master CowAgent
|
||||
rm CowAgent.zip
|
||||
else
|
||||
GIT_HTTP_CONNECT_TIMEOUT=10 GIT_HTTP_LOW_SPEED_LIMIT=1024 GIT_HTTP_LOW_SPEED_TIME=15 \
|
||||
git clone --depth 10 --progress https://github.com/zhayujie/CowAgent.git || {
|
||||
echo -e "${YELLOW}⚠️ GitHub is slow, switching to Gitee mirror...${NC}"
|
||||
git clone --depth 10 --progress https://gitee.com/zhayujie/CowAgent.git
|
||||
}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
local clone_ok=false
|
||||
# Test GitHub connectivity before attempting clone
|
||||
if curl -s --connect-timeout 5 --max-time 10 https://github.com > /dev/null 2>&1; then
|
||||
echo -e "${YELLOW}🌐 GitHub is reachable, cloning from GitHub...${NC}"
|
||||
timeout 15 git clone --depth 10 --progress https://github.com/zhayujie/CowAgent.git && clone_ok=true
|
||||
fi
|
||||
if [ "$clone_ok" = false ]; then
|
||||
echo -e "${YELLOW}⚠️ GitHub clone failed or timed out, switching to Gitee mirror...${NC}"
|
||||
timeout 30 git clone --depth 10 --progress https://gitee.com/zhayujie/CowAgent.git && clone_ok=true
|
||||
fi
|
||||
if [ "$clone_ok" = false ]; then
|
||||
echo -e "${RED}❌ Project clone failed. Please check network connection.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -90,20 +90,37 @@ function Install-Project {
|
||||
}
|
||||
|
||||
Write-Cow "Cloning CowAgent project..."
|
||||
$prevEAP = $ErrorActionPreference; $ErrorActionPreference = "Continue"
|
||||
git clone https://github.com/zhayujie/CowAgent.git 2>&1 | Out-Null
|
||||
$cloneExit = $LASTEXITCODE
|
||||
$ErrorActionPreference = $prevEAP
|
||||
if ($cloneExit -ne 0) {
|
||||
Write-Warn "GitHub failed, trying Gitee..."
|
||||
$ErrorActionPreference = "Continue"
|
||||
git clone https://gitee.com/zhayujie/CowAgent.git 2>&1 | Out-Null
|
||||
$cloneExit = $LASTEXITCODE
|
||||
$ErrorActionPreference = $prevEAP
|
||||
if ($cloneExit -ne 0) {
|
||||
Write-Err "Clone failed. Check your network."
|
||||
exit 1
|
||||
$cloneOk = $false
|
||||
|
||||
# Test GitHub connectivity before attempting clone
|
||||
try {
|
||||
$null = Invoke-WebRequest -Uri "https://github.com" -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
|
||||
Write-Cow "GitHub is reachable, cloning from GitHub..."
|
||||
$proc = Start-Process -FilePath "git" -ArgumentList "clone","--depth","10","--progress","https://github.com/zhayujie/CowAgent.git" `
|
||||
-NoNewWindow -PassThru -RedirectStandardError "$env:TEMP\git_clone_err.txt"
|
||||
if ($proc.WaitForExit(15000) -and $proc.ExitCode -eq 0) {
|
||||
$cloneOk = $true
|
||||
} else {
|
||||
if (-not $proc.HasExited) { $proc.Kill() }
|
||||
if (Test-Path "CowAgent") { Remove-Item -Recurse -Force "CowAgent" }
|
||||
}
|
||||
} catch {}
|
||||
|
||||
if (-not $cloneOk) {
|
||||
Write-Warn "GitHub clone failed or timed out, switching to Gitee mirror..."
|
||||
$proc = Start-Process -FilePath "git" -ArgumentList "clone","--depth","10","--progress","https://gitee.com/zhayujie/CowAgent.git" `
|
||||
-NoNewWindow -PassThru -RedirectStandardError "$env:TEMP\git_clone_err.txt"
|
||||
if ($proc.WaitForExit(30000) -and $proc.ExitCode -eq 0) {
|
||||
$cloneOk = $true
|
||||
} else {
|
||||
if (-not $proc.HasExited) { $proc.Kill() }
|
||||
if (Test-Path "CowAgent") { Remove-Item -Recurse -Force "CowAgent" }
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $cloneOk) {
|
||||
Write-Err "Clone failed. Check your network."
|
||||
exit 1
|
||||
}
|
||||
|
||||
Set-Location "CowAgent"
|
||||
|
||||
Reference in New Issue
Block a user