MCPcopy Create free account
hub / github.com/libgit2/pygit2 / git_proxy_options

Function git_proxy_options

pygit2/callbacks.py:402–421  ·  view source on GitHub ↗
(
    payload: object,
    opts: Optional['GitProxyOptionsC'] = None,
    proxy: None | bool | str = None,
)

Source from the content-addressed store, hash-verified

400
401@contextmanager
402def git_proxy_options(
403 payload: object,
404 opts: Optional['GitProxyOptionsC'] = None,
405 proxy: None | bool | str = None,
406) -> Generator['GitProxyOptionsC', None, None]:
407 if opts is None:
408 opts = ffi.new('git_proxy_options *')
409 C.git_proxy_options_init(opts, C.GIT_PROXY_OPTIONS_VERSION)
410 if proxy is None:
411 opts.type = C.GIT_PROXY_NONE
412 elif proxy is True:
413 opts.type = C.GIT_PROXY_AUTO
414 elif type(proxy) is str:
415 opts.type = C.GIT_PROXY_SPECIFIED
416 # Keep url in memory, otherwise memory is freed and bad things happen
417 payload.__proxy_url = ffi.new('char[]', to_bytes(proxy)) # type: ignore[attr-defined]
418 opts.url = payload.__proxy_url # type: ignore[attr-defined]
419 else:
420 raise TypeError('Proxy must be None, True, or a string')
421 yield opts
422
423
424@contextmanager

Callers 4

clone_repositoryFunction · 0.85
connectMethod · 0.85
fetchMethod · 0.85
pushMethod · 0.85

Calls 1

to_bytesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…