Skip to content

Commit b5eee91

Browse files
committed
fix(git): HTTP(S)_PROXY only in process scope to prevent race condition
1 parent 2accaae commit b5eee91

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

lib/core.ps1

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,25 +155,18 @@ function Invoke-Git {
155155
}
156156

157157
if($ArgumentList -Match '\b(clone|checkout|pull|fetch|ls-remote)\b') {
158-
$old_https = $env:HTTPS_PROXY
159-
$old_http = $env:HTTP_PROXY
160-
try {
158+
$j = Start-Job -ScriptBlock {
161159
# convert proxy setting for git
162-
if ($proxy.StartsWith('currentuser@')) {
160+
$proxy = $using:proxy
161+
if ($proxy -and $proxy.StartsWith('currentuser@')) {
163162
$proxy = $proxy.Replace('currentuser@', ':@')
164163
}
165164
$env:HTTPS_PROXY = $proxy
166165
$env:HTTP_PROXY = $proxy
167-
return & $git @ArgumentList
168-
}
169-
catch {
170-
error $_
171-
return
172-
}
173-
finally {
174-
$env:HTTPS_PROXY = $old_https
175-
$env:HTTP_PROXY = $old_http
166+
& $using:git @using:ArgumentList
176167
}
168+
$o = $j | Receive-Job -Wait -AutoRemoveJob
169+
return $o
177170
}
178171

179172
return & $git @ArgumentList

0 commit comments

Comments
 (0)