livrare.ps1: mesajul de commit prin fisier, nu prin -m
PowerShell 5.1 nu escapeaza argumentele catre exe native, deci ghilimele duble in mesaj (ex. un commit de "sync SVN") spargeau apelul git. Mesajul se scrie intr-un fisier temporar si se foloseste git commit -F, sters in finally. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014sNn6dmAimtyXkDU4frJrh
This commit is contained in:
@@ -349,7 +349,7 @@ function Invoke-PushCuRebaseRetry($repoPath, $eticheta) {
|
||||
return 0
|
||||
}
|
||||
|
||||
function Comite-Si-Impinge($repoPath, $eticheta, $faraPush) {
|
||||
function Comite-Si-Impinge($repoPath, $eticheta, $faraPush, $mesajFile) {
|
||||
# mesajele folosesc Write-Host (nu Write-Output): functia e apelata cu rezultatul
|
||||
# capturat intr-o variabila, iar Write-Output ar ajunge in valoarea returnata.
|
||||
if (-not (Test-Path (Join-Path $repoPath '.git'))) {
|
||||
@@ -363,7 +363,9 @@ function Comite-Si-Impinge($repoPath, $eticheta, $faraPush) {
|
||||
return 0
|
||||
}
|
||||
$ramura = (& git -C $repoPath rev-parse --abbrev-ref HEAD)
|
||||
& git -C $repoPath commit -m $Mesaj | Out-Null
|
||||
# -F <fisier>, nu -m $Mesaj: PowerShell 5.1 nu escapeaza ghilimele/backtick/$ cand paseaza
|
||||
# argumente catre un exe nativ - un mesaj cu ghilimele duble ("sync SVN") sparge -m $Mesaj.
|
||||
& git -C $repoPath commit -F $mesajFile | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host ('[5] ' + $eticheta + ': COMMIT ESUAT pe ramura ' + $ramura)
|
||||
return 1
|
||||
@@ -376,12 +378,25 @@ function Comite-Si-Impinge($repoPath, $eticheta, $faraPush) {
|
||||
return (Invoke-PushCuRebaseRetry $repoPath $eticheta)
|
||||
}
|
||||
|
||||
$exitCode += (Comite-Si-Impinge $ProjectRoot 'proiect' $FaraPush)
|
||||
# mesajul de commit trece printr-un fisier temporar (nu ca argument -m): singurul mod sigur
|
||||
# de a duce prin PowerShell->exe nativ un text cu ghilimele/backtick/$/linii multiple/"-" la
|
||||
# inceput de linie fara sa fie interpretat sau trunchiat. Sters mereu, inclusiv pe esec.
|
||||
$mesajDir = $null
|
||||
try {
|
||||
$mesajDir = Join-Path ([System.IO.Path]::GetTempPath()) ('livrare_' + [guid]::NewGuid().ToString('N'))
|
||||
New-Item -ItemType Directory -Path $mesajDir | Out-Null
|
||||
$mesajFile = Join-Path $mesajDir 'mesaj_commit.txt'
|
||||
$Mesaj | Out-File -FilePath $mesajFile -Encoding utf8
|
||||
|
||||
if ($Comun) {
|
||||
$exitCode += (Comite-Si-Impinge $comunPath 'COMUN' $FaraPush)
|
||||
} elseif ($modifComun.Count -gt 0) {
|
||||
Write-Output ('[5] COMUN: ' + $modifComun.Count + ' fisiere necomise - nu se comite fara -Comun')
|
||||
$exitCode += (Comite-Si-Impinge $ProjectRoot 'proiect' $FaraPush $mesajFile)
|
||||
|
||||
if ($Comun) {
|
||||
$exitCode += (Comite-Si-Impinge $comunPath 'COMUN' $FaraPush $mesajFile)
|
||||
} elseif ($modifComun.Count -gt 0) {
|
||||
Write-Output ('[5] COMUN: ' + $modifComun.Count + ' fisiere necomise - nu se comite fara -Comun')
|
||||
}
|
||||
} finally {
|
||||
if ($mesajDir -and (Test-Path $mesajDir)) { Remove-Item -LiteralPath $mesajDir -Recurse -Force -ErrorAction SilentlyContinue }
|
||||
}
|
||||
|
||||
if ($exitCode -gt 0) { exit 3 }
|
||||
|
||||
Reference in New Issue
Block a user