(
payload: object,
opts: Optional['GitProxyOptionsC'] = None,
proxy: None | bool | str = None,
)
| 400 | |
| 401 | @contextmanager |
| 402 | def 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 |
no test coverage detected
searching dependent graphs…