@@ -65,46 +65,21 @@ function Invoke-GitClone {
6565 if ($Branch ) { $args += @ (" -b" , $Branch ) }
6666 $args += @ ($Url , $Target )
6767
68- $psi = New-Object System.Diagnostics.ProcessStartInfo
69- $psi.FileName = " git"
70- $psi.Arguments = ($args -join " " )
71- $psi.RedirectStandardOutput = $true
72- $psi.RedirectStandardError = $true
73- $psi.UseShellExecute = $false
74- $psi.CreateNoWindow = $true
75-
76- $p = New-Object System.Diagnostics.Process
77- $p.StartInfo = $psi
78-
79- # Collect output asynchronously
80- $stdout = New-Object System.Text.StringBuilder
81- $stderr = New-Object System.Text.StringBuilder
82-
83- $p.add_OutputDataReceived ({
84- if ($_.Data ) { $stdout.AppendLine ($_.Data ) | Out-Null }
85- })
86-
87- $p.add_ErrorDataReceived ({
88- if ($_.Data ) { $stderr.AppendLine ($_.Data ) | Out-Null }
89- })
90-
91- $p.Start () | Out-Null
92- $p.BeginOutputReadLine ()
93- $p.BeginErrorReadLine ()
68+ # Run git with normal PowerShell invocation
69+ $result = git @args 2>&1
9470
95- $p.WaitForExit ()
96-
97- # Write logs
71+ # Logging
9872 if ($LogFile ) {
99- if ($stdout.Length -gt 0 ) { Add-Content $LogFile $stdout.ToString () }
100- if ($stderr.Length -gt 0 ) { Add-Content $LogFile $stderr.ToString () }
73+ $result | Out-File - FilePath $LogFile - Append
10174 }
10275
103- if ($p.ExitCode -ne 0 ) {
104- throw " git clone failed (exit $ ( $p.ExitCode ) ): $ ( $stderr.ToString ()) "
76+ # Detect failure
77+ if ($LASTEXITCODE -ne 0 ) {
78+ throw " git clone failed (exit $LASTEXITCODE ): $result "
10579 }
10680}
10781
82+
10883function Set-ContentNoBom {
10984 param (
11085 [Parameter (Mandatory )][string ]$Path ,
0 commit comments