Skip to content

Commit

Permalink
fix(git): HTTP(S)_PROXY only in process scope to prevent race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
r15ch13 committed Mar 20, 2023
1 parent 2accaae commit b5eee91
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,18 @@ function Invoke-Git {
}

if($ArgumentList -Match '\b(clone|checkout|pull|fetch|ls-remote)\b') {
$old_https = $env:HTTPS_PROXY
$old_http = $env:HTTP_PROXY
try {
$j = Start-Job -ScriptBlock {
# convert proxy setting for git
if ($proxy.StartsWith('currentuser@')) {
$proxy = $using:proxy
if ($proxy -and $proxy.StartsWith('currentuser@')) {
$proxy = $proxy.Replace('currentuser@', ':@')
}
$env:HTTPS_PROXY = $proxy
$env:HTTP_PROXY = $proxy
return & $git @ArgumentList
}
catch {
error $_
return
}
finally {
$env:HTTPS_PROXY = $old_https
$env:HTTP_PROXY = $old_http
& $using:git @using:ArgumentList
}
$o = $j | Receive-Job -Wait -AutoRemoveJob
return $o
}

return & $git @ArgumentList
Expand Down

0 comments on commit b5eee91

Please sign in to comment.