Created
April 13, 2017 09:51
-
-
Save WimObiwan/df5b7fe18f57374cdc34653f2065a84b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on http://stackoverflow.com/a/38381054/5247022 | |
function Invoke-Git { | |
<# | |
.Synopsis | |
Wrapper function that deals with Powershell's peculiar error output when Git uses the error stream. | |
.Example | |
Invoke-Git ThrowError | |
$LASTEXITCODE | |
#> | |
[CmdletBinding()] | |
param( | |
[parameter(ValueFromRemainingArguments=$true)] | |
[string[]]$Arguments | |
) | |
& { | |
[CmdletBinding()] | |
param( | |
[parameter(ValueFromRemainingArguments=$true)] | |
[string[]]$InnerArgs | |
) | |
git.exe $InnerArgs | |
} -ErrorAction SilentlyContinue -ErrorVariable fail @Arguments | |
$resultcode = $LASTEXITCODE | |
if ($fail) { | |
$fail.Exception | |
} | |
if ($resultcode -ne 0) { | |
Write-Error "Git.exe failed with exitcode $resultcode" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment