Skip to content

Commit b15191d

Browse files
authored
Merge branch 'master' into typecheck-part-1
2 parents 5ceb724 + 84310f3 commit b15191d

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

pygit2/__init__.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
2424
# Boston, MA 02110-1301, USA.
2525

26+
# ruff: noqa: F401 F403 F405
27+
2628
# Standard Library
27-
import functools # noqa: I001
28-
from os import PathLike
29+
import functools
30+
import os
2931
import typing
3032

3133
# Low level API
32-
from ._pygit2 import * # noqa: F403
33-
from ._pygit2 import _cache_enums
34+
from ._pygit2 import *
3435

3536
# High level API
3637
from . import enums
@@ -65,8 +66,9 @@
6566
_cache_enums()
6667

6768

69+
6870
def init_repository( # noqa: PLR0913
69-
path: typing.Union[str, bytes, PathLike, None],
71+
path: typing.Union[str, bytes, os.PathLike, None],
7072
bare: bool = False,
7173
flags: enums.RepositoryInitFlag = enums.RepositoryInitFlag.MKPATH,
7274
mode: typing.Union[

pygit2/ffi.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
# Boston, MA 02110-1301, USA.
2525

2626
# Import from pygit2
27+
2728
from ._libgit2 import ffi, lib as C # noqa: I001, F401

pygit2/remotes.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def push_refspecs(self):
237237
check_error(err)
238238
return strarray_to_strings(specs)
239239

240-
def push(self, specs, callbacks=None, proxy=None, push_options=None):
240+
def push(self, specs, callbacks=None, proxy=None, push_options=None, threads=1):
241241
"""
242242
Push the given refspec to the remote. Raises ``GitError`` on protocol
243243
error or unpack failure.
@@ -263,9 +263,19 @@ def push(self, specs, callbacks=None, proxy=None, push_options=None):
263263
push_options : [str]
264264
Push options to send to the server, which passes them to the
265265
pre-receive as well as the post-receive hook.
266+
267+
threads : int
268+
If the transport being used to push to the remote requires the
269+
creation of a pack file, this controls the number of worker threads
270+
used by the packbuilder when creating that pack file to be sent to
271+
the remote.
272+
273+
If set to 0, the packbuilder will auto-detect the number of threads
274+
to create. The default value is 1.
266275
"""
267276
with git_push_options(callbacks) as payload:
268277
opts = payload.push_options
278+
opts.pb_parallelism = threads
269279
self.__set_proxy(opts.proxy_opts, proxy)
270280
with StrArray(specs) as refspecs, StrArray(push_options) as pushopts:
271281
pushopts.assign_to(opts.remote_push_options)

test/test_remote.py

+16
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,19 @@ def test_push_options(origin, clone, remote): # noqa: ARG001
466466
remote_push_options = callbacks.push_options.remote_push_options
467467
assert remote_push_options.count == 2 # noqa: PLR2004
468468
# strings pointed to by remote_push_options.strings[] are already freed
469+
470+
471+
def test_push_threads(origin, clone, remote):
472+
from pygit2 import RemoteCallbacks
473+
474+
callbacks = RemoteCallbacks()
475+
remote.push(['refs/heads/master'], callbacks)
476+
assert callbacks.push_options.pb_parallelism == 1
477+
478+
callbacks = RemoteCallbacks()
479+
remote.push(['refs/heads/master'], callbacks, threads=0)
480+
assert callbacks.push_options.pb_parallelism == 0
481+
482+
callbacks = RemoteCallbacks()
483+
remote.push(['refs/heads/master'], callbacks, threads=1)
484+
assert callbacks.push_options.pb_parallelism == 1

0 commit comments

Comments
 (0)