gitbolt 0.0.0.dev20__tar.gz → 0.0.0.dev21__tar.gz

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.
Files changed (38) hide show
  1. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/PKG-INFO +2 -2
  2. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/README.md +1 -1
  3. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/pyproject.toml +1 -1
  4. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/base.py +15 -4
  5. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/utils/session.py +10 -3
  6. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt.egg-info/PKG-INFO +2 -2
  7. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/LICENSE +0 -0
  8. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/setup.cfg +0 -0
  9. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/__init__.py +0 -0
  10. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/_internal_init.py +0 -0
  11. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/add.py +0 -0
  12. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/base.py +0 -0
  13. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/constants.py +0 -0
  14. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/exceptions.py +0 -0
  15. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/ls_tree.py +0 -0
  16. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/models.py +0 -0
  17. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/py.typed +0 -0
  18. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/pytest_plugin.py +0 -0
  19. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/__init__.py +0 -0
  20. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/_internal_init.py +0 -0
  21. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/add.py +0 -0
  22. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/constants.py +0 -0
  23. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/exceptions.py +0 -0
  24. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/impl/__init__.py +0 -0
  25. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/impl/simple.py +0 -0
  26. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/ls_tree.py +0 -0
  27. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/runner/__init__.py +0 -0
  28. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/runner/base.py +0 -0
  29. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/runner/simple.py +0 -0
  30. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/utils/__init__.py +0 -0
  31. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/utils/cmd.py +0 -0
  32. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/subprocess/utils/models.py +0 -0
  33. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt/utils.py +0 -0
  34. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt.egg-info/SOURCES.txt +0 -0
  35. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt.egg-info/dependency_links.txt +0 -0
  36. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt.egg-info/entry_points.txt +0 -0
  37. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt.egg-info/requires.txt +0 -0
  38. {gitbolt-0.0.0.dev20 → gitbolt-0.0.0.dev21}/src/gitbolt.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitbolt
3
- Version: 0.0.0.dev20
3
+ Version: 0.0.0.dev21
4
4
  Summary: Fast, flexible and type-safe Git commands in Python.
5
5
  Author-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
6
6
  Maintainer-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
@@ -386,7 +386,7 @@ with git.session(
386
386
  cat_file2=["cat-file", "--batch"],
387
387
  cat_file3=lambda: git.subcmd_unchecked.popen(["cat-file", "--batch"]), # pass your own git subcmd Popen(s)
388
388
  mktree=["mktree", "--batch", "-z"]
389
- ) as ses:
389
+ ) as ses: # reusable and reentrant session
390
390
  tree_data: list[bytes] = []
391
391
  for mode_, sha_, name_ in cat_file_tree_data(ses.commands.cat_file2, b"HEAD^{tree}"):
392
392
  print(mode_, sha_, name_)
@@ -350,7 +350,7 @@ with git.session(
350
350
  cat_file2=["cat-file", "--batch"],
351
351
  cat_file3=lambda: git.subcmd_unchecked.popen(["cat-file", "--batch"]), # pass your own git subcmd Popen(s)
352
352
  mktree=["mktree", "--batch", "-z"]
353
- ) as ses:
353
+ ) as ses: # reusable and reentrant session
354
354
  tree_data: list[bytes] = []
355
355
  for mode_, sha_, name_ in cat_file_tree_data(ses.commands.cat_file2, b"HEAD^{tree}"):
356
356
  print(mode_, sha_, name_)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gitbolt"
3
- version = "0.0.0.dev20"
3
+ version = "0.0.0.dev21"
4
4
  description = "Fast, flexible and type-safe Git commands in Python."
5
5
  requires-python = ">=3.12"
6
6
  readme = "README.md"
@@ -392,18 +392,20 @@ class GitSession(HasGitUnderneath[GitCommand], AbstractContextManager):
392
392
  :param commands: commands in kwargs fashion.
393
393
  """
394
394
  self._git = git
395
- self.unstarted_commands: dict[str, Callable[[], Popen[bytes]]] = commands
395
+ self.all_supplied_commands: dict[str, Callable[[], Popen[bytes]]] = commands.copy()
396
396
  self.started_commands: dict[str, Popen[bytes]] = dict()
397
397
  self._commands: SimpleNamespace | None = None
398
398
  self.__started = False
399
399
  self.__done = False
400
400
  self.__depth = 0
401
+ self.__times_reused = -1
401
402
 
402
403
  @override
403
404
  def __enter__(self) -> Self:
404
405
  if self.depth == 0:
406
+ self.__done = False
405
407
  processes_started_keys: list[str] = []
406
- for unstarted_command_key, unstarted_command in self.unstarted_commands.items():
408
+ for unstarted_command_key, unstarted_command in self.all_supplied_commands.items():
407
409
  try:
408
410
  self.started_commands[unstarted_command_key] = unstarted_command().__enter__()
409
411
  except Exception:
@@ -412,9 +414,8 @@ class GitSession(HasGitUnderneath[GitCommand], AbstractContextManager):
412
414
  raise
413
415
  processes_started_keys.append(unstarted_command_key)
414
416
  self._commands = SimpleNamespace(**self.started_commands)
415
- for pk in processes_started_keys:
416
- del self.unstarted_commands[pk]
417
417
  self.__started = True
418
+ self.__times_reused += 1
418
419
  self.__depth += 1
419
420
  return self
420
421
 
@@ -475,6 +476,16 @@ class GitSession(HasGitUnderneath[GitCommand], AbstractContextManager):
475
476
  """
476
477
  return self.__depth
477
478
 
479
+ def is_reused(self) -> bool:
480
+ """
481
+ :returns: The session is reused after being closed once.
482
+ """
483
+ return self.__times_reused > 0
484
+
485
+ @property
486
+ def times_reused(self) -> int:
487
+ return self.__times_reused
488
+
478
489
 
479
490
  class GitSubcmdCommand(GitSubCommand, HasGitUnderneath["GitCommand"], Protocol):
480
491
  """
@@ -570,14 +570,21 @@ if __name__ == "__main__":
570
570
  end = time.perf_counter()
571
571
  print(f"Subcmd Elapsed time: {end - start:0.4f} seconds")
572
572
 
573
- with git.session(
573
+ session = git.session(
574
574
  cat_file=["cat-file", "--batch"],
575
575
  for_each_ref_contains=["for-each-ref", "--stdin"],
576
576
  rev_list_contains=["rev-list", "--stdin"],
577
- ) as ses:
577
+ )
578
+ with session as ses:
578
579
  print(cat_file_commit_data(ses.commands.cat_file, b"d7d8d6f79017c5d574e3c4ac519c855b7cec33e2"))
579
580
  print(cat_file_commit_data(ses.commands.cat_file, b"HEAD"))
580
- print(cat_file_commit_data(ses.commands.cat_file, b"a744fefd4eaf1a0139ae3c85f713a1a963563cc3"))
581
581
  print(single_shot_command(ses.commands.rev_list_contains, b"develop\n\n", False))
582
582
  # print(single_shot_command(ses.commands.rev_list_contains, b"develop\n\n", False))
583
+ print(cat_file_commit_data(ses.commands.cat_file, b"a744fefd4eaf1a0139ae3c85f713a1a963563cc3"))
584
+ print("$"*40)
585
+ with session as ses:
586
+ print(cat_file_commit_data(ses.commands.cat_file, b"d7d8d6f79017c5d574e3c4ac519c855b7cec33e2"))
587
+ print(cat_file_commit_data(ses.commands.cat_file, b"HEAD"))
588
+ print(cat_file_commit_data(ses.commands.cat_file, b"a744fefd4eaf1a0139ae3c85f713a1a963563cc3"))
589
+ print(single_shot_command(ses.commands.rev_list_contains, b"develop\n\n", False))
583
590
  # endregion
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitbolt
3
- Version: 0.0.0.dev20
3
+ Version: 0.0.0.dev21
4
4
  Summary: Fast, flexible and type-safe Git commands in Python.
5
5
  Author-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
6
6
  Maintainer-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
@@ -386,7 +386,7 @@ with git.session(
386
386
  cat_file2=["cat-file", "--batch"],
387
387
  cat_file3=lambda: git.subcmd_unchecked.popen(["cat-file", "--batch"]), # pass your own git subcmd Popen(s)
388
388
  mktree=["mktree", "--batch", "-z"]
389
- ) as ses:
389
+ ) as ses: # reusable and reentrant session
390
390
  tree_data: list[bytes] = []
391
391
  for mode_, sha_, name_ in cat_file_tree_data(ses.commands.cat_file2, b"HEAD^{tree}"):
392
392
  print(mode_, sha_, name_)
File without changes
File without changes