Private/Invoke-CCGit.ps1
|
function Invoke-CCGit { <# .SYNOPSIS Runs git in a repository and returns whether it succeeded, with its output. .NOTES A failure is returned, not thrown, so that the caller can say what to do about it. The arguments are one array because PowerShell would otherwise swallow a bare '--'. #> param( [Parameter(Mandatory)][string]$Path, [Parameter(Mandatory)][string[]]$Arguments ) $output = & git -C $Path @Arguments 2>&1 [pscustomobject]@{ Ok = ($LASTEXITCODE -eq 0) Output = (@($output) -join "`n").Trim() } } |