Skip to content

Commit 29f1b10

Browse files
committed
Enable automatic proxy detection for remote push()
See #642
1 parent a3145c1 commit 29f1b10

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pygit2/remote.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def push_refspecs(self):
237237

238238
return strarray_to_strings(specs)
239239

240-
def push(self, specs, callbacks=None):
240+
def push(self, specs, callbacks=None, proxy=None):
241241
"""
242242
Push the given refspec to the remote. Raises ``GitError`` on protocol
243243
error or unpack failure.
@@ -252,9 +252,21 @@ def push(self, specs, callbacks=None):
252252
253253
specs : [str]
254254
Push refspecs to use.
255+
256+
proxy : None or True or str
257+
Proxy configuration. Can be one of:
258+
259+
* `None` (the default) to disable proxy usage
260+
* `True` to enable automatic proxy detection
261+
* an url to a proxy (`http://proxy.example.org:3128/`)
255262
"""
256263
with git_push_options(callbacks) as payload:
257264
opts = payload.push_options
265+
if proxy is True:
266+
opts.proxy_opts.type = C.GIT_PROXY_AUTO
267+
elif proxy is not None:
268+
opts.proxy_opts.type = C.GIT_PROXY_SPECIFIED
269+
opts.proxy_opts.url = proxy
258270
with StrArray(specs) as refspecs:
259271
err = C.git_remote_push(self._remote, refspecs, opts)
260272
payload.check_error(err)

0 commit comments

Comments
 (0)