@@ -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) 个变更路径。"
|
||||
|
||||
Reference in New Issue
Block a user