修复Gitea合并提交构建失败
发布 Nacos 配置 / publish (push) Successful in 37s

This commit is contained in:
2026-08-28 13:07:49 +08:00
parent 1bec2e5bcd
commit b0181edbd3
3 changed files with 18 additions and 2 deletions
@@ -475,8 +475,16 @@ function Invoke-RemoteShellMany {
function Test-GitState {
Push-Location $resolvedRepoRoot
try {
$commit = (& git rev-parse HEAD).Trim()
$branch = (& git branch --show-current).Trim()
$commitOutput = & git rev-parse HEAD
if ($LASTEXITCODE -ne 0 -or $null -eq $commitOutput) {
throw "无法读取当前 Git 提交号。"
}
$commit = ([string]$commitOutput).Trim()
$branchOutput = & git branch --show-current
$branch = if ($null -ne $branchOutput) { ([string]$branchOutput).Trim() } else { "" }
if (-not $branch) {
$branch = if ($env:GITHUB_REF_NAME) { ([string]$env:GITHUB_REF_NAME).Trim() } else { "DETACHED_HEAD" }
}
$status = @(& git status --porcelain)
if ($status.Count -gt 0) {
Write-Warning "当前工作区有 $($status.Count) 个变更路径。"