From b63318709e44d6868838a98e9435d63c93d72d47 Mon Sep 17 00:00:00 2001 From: wangbolhr Date: Fri, 10 Apr 2026 16:44:58 +0800 Subject: [PATCH] =?UTF-8?q?chore(start.ps1):=20=E7=A7=BB=E9=99=A4=20Git=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=89=E8=A3=85=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 部署脚本不依赖本机 git,winget/choco 安装与 PATH 刷新已无必要。 Made-with: Cursor --- start.ps1 | 76 ------------------------------------------------------- 1 file changed, 76 deletions(-) diff --git a/start.ps1 b/start.ps1 index 4a495e3..9488a5e 100644 --- a/start.ps1 +++ b/start.ps1 @@ -151,81 +151,6 @@ function Setup-EnvFiles { Ok ".env configured for IP=$($script:DeployIP)" } -function Test-GitInstalled { - $git = Get-Command git -ErrorAction SilentlyContinue - if (-not $git) { return $false } - try { & git --version *> $null; return $true } catch { return $false } -} - -function Refresh-SessionPath { - try { - $machine = [Environment]::GetEnvironmentVariable("Path", "Machine") - $user = [Environment]::GetEnvironmentVariable("Path", "User") - $parts = @($machine, $user) | Where-Object { $_ } - if ($parts.Count -gt 0) { $env:Path = ($parts -join ";") } - } catch { } -} - -function Install-Git { - if (Get-Command winget -ErrorAction SilentlyContinue) { - Step "Installing Git via winget..." - Write-Log "winget install Git.Git" - winget install --id Git.Git -e --accept-source-agreements --accept-package-agreements - if ($LASTEXITCODE -eq 0) { - Start-Sleep -Seconds 2 - Refresh-SessionPath - if (Test-GitInstalled) { - Ok "Git installed" - Write-Log "Git available after winget (PATH refreshed)" - return - } - Ok "Git installed. Close this terminal, open a new one, then run this script again." - Write-Log "Git installed via winget, user must refresh shell" - exit 0 - } - } - if (Get-Command choco -ErrorAction SilentlyContinue) { - Step "Installing Git via Chocolatey..." - Write-Log "choco install git" - choco install git -y - if ($LASTEXITCODE -eq 0) { - Start-Sleep -Seconds 2 - Refresh-SessionPath - if (Test-GitInstalled) { - Ok "Git installed" - Write-Log "Git available after choco (PATH refreshed)" - return - } - Ok "Git installed. Close this terminal, open a new one, then run this script again." - Write-Log "Git installed via choco, user must refresh shell" - exit 0 - } - } - Warn "Could not install Git automatically. Please install manually:" - Write-Host " https://git-scm.com/download/win" - Write-Log "Git auto-install failed, user must install manually" - Wait-ForExit - exit 1 -} - -function Ensure-Git { - if ($env:DEPLOY_SKIP_GIT -eq "1") { return } - if ($env:CI -eq "true") { return } - if ($script:DeployDryRun) { return } - if (Test-GitInstalled) { - Ok "Git installed" - return - } - Write-Host "" - Write-Host "================================" - Write-Host " Git Check" - Write-Host "================================" - Write-Host "" - Warn "Git not found. Attempting automatic install..." - Write-Log "Git missing, running Install-Git" - Install-Git -} - function Test-DockerInstalled { $docker = Get-Command docker -ErrorAction SilentlyContinue if (-not $docker) { return $false } @@ -346,7 +271,6 @@ function Start-Services { function Main { Init-ProjectDir - Ensure-Git if ((Test-Path ".env") -and -not $env:DEPLOY_FORCE_RECONFIG -and -not $env:DEPLOY_IP) { $answer = (Read-Host "Existing .env found. Reconfigure? [y/N]").Trim().ToLower()