gitbolt 0.0.0.dev26__py3-none-any.whl → 0.0.0.dev27__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,6 +35,7 @@ from gitbolt.models import GitOpts, GitLsTreeOpts, GitAddOpts, GitEnvVars
35
35
  from gitbolt.subprocess.worktree import WorktreeCLIArgsBuilder
36
36
  from gitbolt.utils import merge_git_opts, merge_git_envs
37
37
  from gitbolt.subprocess.constants import GIT_CMD, VERSION_CMD, LS_TREE_CMD, ADD_CMD, WORKTREE_CMD, WORKTREE_ADD_CMD
38
+ from gitbolt.subprocess.utils.session import _close_session_popen
38
39
 
39
40
 
40
41
  class GitCommand(Git, ABC):
@@ -512,7 +513,9 @@ class GitSession(HasGitUnderneath[GitCommand], AbstractContextManager):
512
513
  self.started_commands[unstarted_command_key] = unstarted_command().__enter__()
513
514
  except Exception:
514
515
  for k in reversed(processes_started_keys):
515
- self.started_commands[k].__exit__(*sys.exc_info())
516
+ _close_session_popen(
517
+ self.started_commands[k], *sys.exc_info()
518
+ )
516
519
  raise
517
520
  processes_started_keys.append(unstarted_command_key)
518
521
  self._commands = SimpleNamespace(**self.started_commands)
@@ -532,7 +535,7 @@ class GitSession(HasGitUnderneath[GitCommand], AbstractContextManager):
532
535
  if self.__depth == 0:
533
536
  process_done_keys: list[str] = []
534
537
  for started_popen_key, started_popen in self.started_commands.items():
535
- started_popen.__exit__(exc_type, exc_value, traceback)
538
+ _close_session_popen(started_popen, exc_type, exc_value, traceback)
536
539
  process_done_keys.append(started_popen_key)
537
540
  self._commands = None
538
541
  for pk in process_done_keys:
@@ -8,6 +8,7 @@ Create sessions for long-running commands and communicate with them using their
8
8
 
9
9
  Much faster that subprocess creation for each input/output pair.
10
10
  """
11
+ import errno
11
12
  import subprocess
12
13
  from typing import Iterable, IO, cast
13
14
 
@@ -18,6 +19,25 @@ from gitbolt.subprocess.utils.models import GitRawActor, GitRawSignature, GPGGit
18
19
  RawCommitBytesObj, RawBytesValsOfCommit
19
20
 
20
21
 
22
+ def _close_session_popen(popen: subprocess.Popen[bytes], exc_type, exc_value, traceback) -> None:
23
+ """
24
+ Close a session ``Popen`` and ignore a broken pipe.
25
+
26
+ A git process started with a bad command can exit before the session does. Closing its stdin
27
+ then raises ``BrokenPipeError`` (common on macOS) or a matching ``OSError``.
28
+ """
29
+ try:
30
+ popen.__exit__(exc_type, exc_value, traceback)
31
+ except BrokenPipeError:
32
+ return
33
+ except OSError as err:
34
+ if err.errno in {errno.EPIPE, errno.ECONNRESET}:
35
+ return
36
+ if getattr(err, "winerror", None) in {109, 232}:
37
+ return
38
+ raise
39
+
40
+
21
41
  # region blob
22
42
  def cat_file_blob_content(
23
43
  cat_file_popen: subprocess.Popen[bytes], blob_hash: bytes, require_type: bytes | None = None
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitbolt
3
- Version: 0.0.0.dev26
3
+ Version: 0.0.0.dev27
4
4
  Summary: Fast, flexible and type-safe Git commands in Python.
5
- Author-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
5
+ Author-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>, Thamotharan R <thamotharan.r@vaastav.tech>
6
6
  Maintainer-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
7
7
  License-Expression: Apache-2.0
8
8
  Project-URL: homepage, https://github.com/Vaastav-Technologies/py-gitbolt
@@ -12,7 +12,7 @@ gitbolt/utils.py,sha256=GGD1XBj0lQ8Z1ygItZl-k69fyrxQGzeID15f3yiWzGc,7275
12
12
  gitbolt/subprocess/__init__.py,sha256=DxAPZ3Zuah5Li0c7z-Oud9bB-Api3DGvkvgKTEalsQI,623
13
13
  gitbolt/subprocess/_internal_init.py,sha256=C6jfsbjXhIFHaDH9GE-wLPAN9WMlUU57rRLWvfpZuAs,255
14
14
  gitbolt/subprocess/add.py,sha256=EDBEbBaVvxAkk3jAfrVAKSuwhln8uJiv-Tq0Pc5kuig,17273
15
- gitbolt/subprocess/base.py,sha256=ztx7pV1GkF4EKXV_pCwvesxuvC80KJU_leUp4s6UbfU,51721
15
+ gitbolt/subprocess/base.py,sha256=SOE9NFx-evSv7qOifVvp7EeEys_Jisu7UM-bkAXg0HE,51867
16
16
  gitbolt/subprocess/constants.py,sha256=qYFI-YoJUcSDoXKD7qZZvddK6Y6QD9KldQ8hYp9oJ48,612
17
17
  gitbolt/subprocess/exceptions.py,sha256=xLqkKPnya0O-N12sxfQDX9YQZilgDj-OOAT09lYrjrY,4043
18
18
  gitbolt/subprocess/ls_tree.py,sha256=qn17b4S-xvzyMoOtgrt7FDzf3eiLMLNG6wAwfsz9SsE,14672
@@ -25,10 +25,10 @@ gitbolt/subprocess/runner/simple.py,sha256=PifHmEx754mrOIQkBA9XvjUqZPPN_dwMPbwM7
25
25
  gitbolt/subprocess/utils/__init__.py,sha256=Xk4jM1i8WsozSWnpxS5SFAICyqGitpCBArhYWVXCjP4,122
26
26
  gitbolt/subprocess/utils/main_cmd.py,sha256=xB9fkdzNYCz7u5-83grlrr9VF-CaJc39CManZCu_L_E,6373
27
27
  gitbolt/subprocess/utils/models.py,sha256=-wBjtHoxMNlZLLr_Ggjn4Jt5FQ6-sdnyRXKxHKIITcE,3216
28
- gitbolt/subprocess/utils/session.py,sha256=BjVG2LrGY64S-QwjbyR9RBL97haassoRHa4KySbFCfw,30651
29
- gitbolt-0.0.0.dev26.dist-info/licenses/LICENSE,sha256=pOzr5bMWS6mHi3vro8d5vw0qW1i14rVq2XFrDuystVY,11372
30
- gitbolt-0.0.0.dev26.dist-info/METADATA,sha256=zQ9KnjG368edDBD9RPFPLbX7mDRuPAoCgufMUG9mKXs,15336
31
- gitbolt-0.0.0.dev26.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
32
- gitbolt-0.0.0.dev26.dist-info/entry_points.txt,sha256=Q078Wjss4skreUs8hzAEJ8sUcH4Rhjc9emZ4jRXCiBM,52
33
- gitbolt-0.0.0.dev26.dist-info/top_level.txt,sha256=QCXclkzSPZjgamcwB6XuKJexaJ1as_TLUUSGdIDA7VY,8
34
- gitbolt-0.0.0.dev26.dist-info/RECORD,,
28
+ gitbolt/subprocess/utils/session.py,sha256=6SZHk08eZ8_hRXepiYAAVUWrGgYMiA_rJd4ESFqQ4fo,31315
29
+ gitbolt-0.0.0.dev27.dist-info/licenses/LICENSE,sha256=pOzr5bMWS6mHi3vro8d5vw0qW1i14rVq2XFrDuystVY,11372
30
+ gitbolt-0.0.0.dev27.dist-info/METADATA,sha256=3-gZshEgjDrFjE1mRjG5WSK57q768sb0aFcCScrXubg,15380
31
+ gitbolt-0.0.0.dev27.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
32
+ gitbolt-0.0.0.dev27.dist-info/entry_points.txt,sha256=Q078Wjss4skreUs8hzAEJ8sUcH4Rhjc9emZ4jRXCiBM,52
33
+ gitbolt-0.0.0.dev27.dist-info/top_level.txt,sha256=QCXclkzSPZjgamcwB6XuKJexaJ1as_TLUUSGdIDA7VY,8
34
+ gitbolt-0.0.0.dev27.dist-info/RECORD,,