Skip to content

Commit e7f14f6

Browse files
committed
Enable automatic proxy detection for remote connect()
See #642
1 parent 7e38cd2 commit e7f14f6

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

pygit2/remote.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,30 @@ def push_url(self):
9191

9292
return maybe_string(C.git_remote_pushurl(self._remote))
9393

94-
def connect(self, callbacks=None, direction=C.GIT_DIRECTION_FETCH):
94+
def connect(self, callbacks=None, direction=C.GIT_DIRECTION_FETCH, proxy=None):
9595
"""Connect to the remote.
96+
97+
Parameters:
98+
99+
proxy : None or True or str
100+
Proxy configuration. Can be one of:
101+
102+
* `None` (the default) to disable proxy usage
103+
* `True` to enable automatic proxy detection
104+
* an url to a proxy (`http://proxy.example.org:3128/`)
96105
"""
106+
if proxy is not None:
107+
proxy_opts = ffi.new('git_proxy_options *')
108+
if proxy is True:
109+
proxy_opts.type = C.GIT_PROXY_AUTO
110+
elif proxy is not None:
111+
proxy_opts.type = C.GIT_PROXY_SPECIFIED
112+
proxy_opts.url = proxy
113+
else:
114+
proxy_opts = ffi.NULL
97115
with git_remote_callbacks(callbacks) as payload:
98116
err = C.git_remote_connect(self._remote, direction,
99-
payload.remote_callbacks, ffi.NULL,
117+
payload.remote_callbacks, proxy_opts,
100118
ffi.NULL)
101119
payload.check_error(err)
102120

0 commit comments

Comments
 (0)