From 634e5c1081b5cb073a1f56c57e164035ab1fdbc0 Mon Sep 17 00:00:00 2001 From: zbc Date: Sun, 11 Oct 2026 17:13:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E8=84=9A=E6=9C=AC=E4=B8=8E=E9=A1=B5=E5=A4=B4?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/git-push.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/git-push.ps1 b/scripts/git-push.ps1 index d2c9db2..dcdd195 100644 --- a/scripts/git-push.ps1 +++ b/scripts/git-push.ps1 @@ -76,9 +76,10 @@ function Write-Ok($text) { Write-Host " $text" -ForegroundColor Green } function Write-Warn2($text){ Write-Host " $text" -ForegroundColor Yellow } # 推送失败时读取错误输出,用于识别「远程有本地没有的提交」这类情况 +# 注意:参数名不能叫 Args —— 那是 PowerShell 的自动变量,会吞掉传入的数组 function Invoke-GitCapture { - param([string[]]$Args) - $out = & git @Args 2>&1 + param([string[]]$GitArgs) + $out = & git @GitArgs 2>&1 return @{ Output = ($out | Out-String).Trim(); Code = $LASTEXITCODE } } @@ -182,7 +183,7 @@ $pushArgs = @("push") if ($Force) { $pushArgs += "--force-with-lease" } $pushArgs += @($pushUrl, $branch) -$result = Invoke-GitCapture -Args $pushArgs +$result = Invoke-GitCapture -GitArgs $pushArgs # 输出里若回显了带凭据的地址,遮蔽掉 $shown = $result.Output if ($tempCred) { @@ -204,7 +205,7 @@ if ($result.Code -eq 0) { $pushArgs = @("push") if ($Force) { $pushArgs += "--force-with-lease" } $pushArgs += @($pushUrl, $branch) - $result = Invoke-GitCapture -Args $pushArgs + $result = Invoke-GitCapture -GitArgs $pushArgs if ($result.Code -ne 0) { Write-Warn2 $result.Output throw "推送仍然失败"