gitbolt 0.0.0.dev5__tar.gz → 0.0.0.dev7__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 (35) hide show
  1. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/PKG-INFO +1 -1
  2. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/pyproject.toml +1 -1
  3. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/__init__.py +2 -0
  4. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/base.py +12 -0
  5. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/constants.py +3 -1
  6. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/base.py +9 -5
  7. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/impl/simple.py +25 -14
  8. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/runner/simple_impl.py +3 -1
  9. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/pytest_plugin.py +1 -0
  10. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt.egg-info/PKG-INFO +1 -1
  11. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/LICENSE +0 -0
  12. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/README.md +0 -0
  13. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/setup.cfg +0 -0
  14. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/_internal_init.py +0 -0
  15. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/add.py +0 -0
  16. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/exceptions.py +0 -0
  17. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/__init__.py +0 -0
  18. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/_internal_init.py +0 -0
  19. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/add.py +0 -0
  20. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/constants.py +0 -0
  21. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/exceptions.py +0 -0
  22. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/impl/__init__.py +0 -0
  23. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/ls_tree.py +0 -0
  24. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/runner/__init__.py +0 -0
  25. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/runner/base.py +0 -0
  26. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/git_subprocess/utils.py +0 -0
  27. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/ls_tree.py +0 -0
  28. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/models.py +0 -0
  29. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/py.typed +0 -0
  30. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt/utils.py +0 -0
  31. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt.egg-info/SOURCES.txt +0 -0
  32. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt.egg-info/dependency_links.txt +0 -0
  33. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt.egg-info/entry_points.txt +0 -0
  34. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/src/gitbolt.egg-info/requires.txt +0 -0
  35. {gitbolt-0.0.0.dev5 → gitbolt-0.0.0.dev7}/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.dev5
3
+ Version: 0.0.0.dev7
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>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gitbolt"
3
- version = "0.0.0dev5"
3
+ version = "0.0.0dev7"
4
4
  description = "Fast, flexible and type-safe Git commands in Python."
5
5
  requires-python = ">=3.12"
6
6
  readme = "README.md"
@@ -4,6 +4,7 @@
4
4
  """
5
5
  Git command interfaces with default implementation using subprocess calls.
6
6
  """
7
+
7
8
  from pathlib import Path
8
9
 
9
10
  # region imports
@@ -38,4 +39,5 @@ def get_git(git_root_dir: Path = Path.cwd()) -> Git:
38
39
  :param git_root_dir: Path to the git repo root directory. Defaults to current working directory.
39
40
  """
40
41
  from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
42
+
41
43
  return SimpleGitCommand(git_root_dir)
@@ -243,6 +243,18 @@ class Version(GitSubCommand, Protocol):
243
243
  """
244
244
  Require that arguments sent to the version command is valid.
245
245
 
246
+ Examples:
247
+
248
+ Correct:
249
+
250
+ >>> Version._require_valid_args()
251
+
252
+ Error:
253
+
254
+ >>> Version._require_valid_args(1) # type: ignore[arg-type] # required bool, supplied int
255
+ Traceback (most recent call last):
256
+ gitbolt.exceptions.GitExitingException: TypeError: build_options should be bool.
257
+
246
258
  :param build_options: argument to be validated.
247
259
  :raise GitExitingException: if supplied ``build_options`` is invalid.
248
260
  """
@@ -4,7 +4,9 @@
4
4
  """
5
5
  Constants related to gitbolt.
6
6
  """
7
+
7
8
  from pathlib import Path
8
9
 
9
- GIT_DIR_STR = '.git'
10
+ GIT_DIR_STR = ".git"
10
11
  GIT_DIR = Path(GIT_DIR_STR)
12
+ GIT_DEFAULT_BRANCH_CONFIG_KEY = "init.defaultbranch"
@@ -340,6 +340,7 @@ class LsTreeCommand(LsTree, GitSubcmdCommand, Protocol):
340
340
  self.args_validator.validate(tree_ish, **ls_tree_opts)
341
341
  sub_cmd_args = self.cli_args_builder.build(tree_ish, **ls_tree_opts)
342
342
  main_cmd_args = self.underlying_git.build_main_cmd_args()
343
+ env_vars = self.underlying_git.build_git_envs()
343
344
 
344
345
  # Run the git command
345
346
  result = self.underlying_git.runner.run_git_command(
@@ -349,6 +350,7 @@ class LsTreeCommand(LsTree, GitSubcmdCommand, Protocol):
349
350
  text=True,
350
351
  capture_output=True,
351
352
  cwd=self.root_dir,
353
+ env=env_vars,
352
354
  )
353
355
 
354
356
  return result.stdout.strip()
@@ -420,6 +422,7 @@ class AddCommand(Add, GitSubcmdCommand, Protocol):
420
422
  **add_opts,
421
423
  )
422
424
  main_cmd_args = self.underlying_git.build_main_cmd_args()
425
+ env_vars = self.underlying_git.build_git_envs()
423
426
 
424
427
  # Run the git command
425
428
  result = self.underlying_git.runner.run_git_command(
@@ -430,6 +433,7 @@ class AddCommand(Add, GitSubcmdCommand, Protocol):
430
433
  text=True,
431
434
  capture_output=True,
432
435
  cwd=self.root_dir,
436
+ env=env_vars,
433
437
  )
434
438
 
435
439
  return result.stdout.strip()
@@ -514,12 +518,12 @@ class UncheckedSubcmd(GitSubcmdCommand, RootDirOp, Protocol):
514
518
  """
515
519
  main_cmd_args = self.underlying_git.build_main_cmd_args()
516
520
  envs_vars = self.underlying_git.build_git_envs()
517
- another_supplied_env = subprocess_run_kwargs.pop('env', None)
521
+ another_supplied_env = subprocess_run_kwargs.pop("env", None)
518
522
  if another_supplied_env:
519
523
  envs_vars.update(another_supplied_env)
520
- cwd = subprocess_run_kwargs.pop('cwd', None) or self.root_dir
521
- capture_output = subprocess_run_kwargs.pop('capture_output', None) or True
522
- check = subprocess_run_kwargs.pop('check', None) or True
524
+ cwd = subprocess_run_kwargs.pop("cwd", None) or self.root_dir
525
+ capture_output = subprocess_run_kwargs.pop("capture_output", None) or True
526
+ check = subprocess_run_kwargs.pop("check", None) or True
523
527
  # Run the git command
524
528
  result = self.underlying_git.runner.run_git_command(
525
529
  main_cmd_args,
@@ -531,6 +535,6 @@ class UncheckedSubcmd(GitSubcmdCommand, RootDirOp, Protocol):
531
535
  cwd=cwd,
532
536
  capture_output=capture_output,
533
537
  check=check,
534
- **subprocess_run_kwargs
538
+ **subprocess_run_kwargs,
535
539
  )
536
540
  return result
@@ -20,7 +20,7 @@ from gitbolt.git_subprocess import (
20
20
  LsTreeCommand,
21
21
  GitSubcmdCommand,
22
22
  AddCommand,
23
- UncheckedSubcmd
23
+ UncheckedSubcmd,
24
24
  )
25
25
  from gitbolt.git_subprocess.add import AddCLIArgsBuilder
26
26
  from gitbolt.git_subprocess.constants import VERSION_CMD
@@ -48,10 +48,16 @@ class VersionCommandImpl(VersionCommand, GitSubcmdCommandImpl):
48
48
  self._require_valid_args(build_options)
49
49
  main_cmd_args = self.underlying_git.build_main_cmd_args()
50
50
  sub_cmd_args = [VERSION_CMD]
51
+ env_vars = self.underlying_git.build_git_envs()
51
52
  if build_options:
52
53
  sub_cmd_args.append("--build-options")
53
54
  return self.underlying_git.runner.run_git_command(
54
- main_cmd_args, sub_cmd_args, check=True, text=True, capture_output=True
55
+ main_cmd_args,
56
+ sub_cmd_args,
57
+ check=True,
58
+ text=True,
59
+ capture_output=True,
60
+ env=env_vars,
55
61
  ).stdout.strip()
56
62
 
57
63
  def clone(self) -> "VersionCommandImpl":
@@ -133,11 +139,7 @@ class AddCommandImpl(AddCommand, GitSubcmdCommandImpl):
133
139
 
134
140
 
135
141
  class UncheckedSubcmdImpl(UncheckedSubcmd, GitSubcmdCommandImpl):
136
- def __init__(
137
- self,
138
- root_dir: Path,
139
- git: GitCommand
140
- ):
142
+ def __init__(self, root_dir: Path, git: GitCommand):
141
143
  super().__init__(git)
142
144
  self._root_dir = root_dir
143
145
 
@@ -151,7 +153,6 @@ class UncheckedSubcmdImpl(UncheckedSubcmd, GitSubcmdCommandImpl):
151
153
 
152
154
 
153
155
  class SimpleGitCommand(GitCommand, RootDirOp):
154
-
155
156
  def __init__(
156
157
  self,
157
158
  git_root_dir: Path = Path.cwd(),
@@ -160,7 +161,7 @@ class SimpleGitCommand(GitCommand, RootDirOp):
160
161
  version_subcmd: VersionCommand | None = None,
161
162
  ls_tree_subcmd: LsTreeCommand | None = None,
162
163
  add_subcmd: AddCommand | None = None,
163
- subcmd_unchecked: UncheckedSubcmd | None = None
164
+ subcmd_unchecked: UncheckedSubcmd | None = None,
164
165
  ):
165
166
  super().__init__(runner)
166
167
  self.git_root_dir = git_root_dir
@@ -172,17 +173,25 @@ class SimpleGitCommand(GitCommand, RootDirOp):
172
173
  @override
173
174
  @property
174
175
  def version_subcmd(self) -> VersionCommand:
175
- return self._version_subcmd
176
+ # TODO: in all subcommand methods, find a better way to retain envs and opts rather than cloning each time
177
+ # and setting the underlying git.
178
+ version_subcmd = self._version_subcmd.clone()
179
+ version_subcmd._set_underlying_git(self)
180
+ return version_subcmd
176
181
 
177
182
  @override
178
183
  @property
179
184
  def ls_tree_subcmd(self) -> LsTreeCommand:
180
- return self._ls_tree
185
+ ls_tree_subcmd = self._ls_tree.clone()
186
+ ls_tree_subcmd._set_underlying_git(self)
187
+ return ls_tree_subcmd
181
188
 
182
189
  @override
183
190
  @property
184
191
  def add_subcmd(self) -> AddCommand:
185
- return self._add_subcmd
192
+ add_subcmd = self._add_subcmd.clone()
193
+ add_subcmd._set_underlying_git(self)
194
+ return add_subcmd
186
195
 
187
196
  @override
188
197
  def clone(self) -> "SimpleGitCommand":
@@ -193,7 +202,7 @@ class SimpleGitCommand(GitCommand, RootDirOp):
193
202
  version_subcmd=self.version_subcmd,
194
203
  ls_tree_subcmd=self.ls_tree_subcmd,
195
204
  add_subcmd=self.add_subcmd,
196
- subcmd_unchecked=self.subcmd_unchecked
205
+ subcmd_unchecked=self.subcmd_unchecked,
197
206
  )
198
207
  # endregion
199
208
  # region clone protected members
@@ -209,4 +218,6 @@ class SimpleGitCommand(GitCommand, RootDirOp):
209
218
 
210
219
  @property
211
220
  def subcmd_unchecked(self) -> UncheckedSubcmd:
212
- return self._subcmd_unchecked
221
+ subcmd_unchecked = self._subcmd_unchecked.clone()
222
+ subcmd_unchecked._set_underlying_git(self)
223
+ return subcmd_unchecked
@@ -86,4 +86,6 @@ class SimpleGitCR(GitCommandRunner):
86
86
  **subprocess_run_kwargs,
87
87
  )
88
88
  except subprocess.CalledProcessError as e:
89
- raise GitCmdException(e.stderr, called_process_error=e, exit_code=e.returncode) from e
89
+ raise GitCmdException(
90
+ e.stderr, called_process_error=e, exit_code=e.returncode
91
+ ) from e
@@ -4,6 +4,7 @@
4
4
  """
5
5
  Third-party importable pytest plugins for ``gitbolt``.
6
6
  """
7
+
7
8
  import subprocess
8
9
  from pathlib import Path
9
10
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitbolt
3
- Version: 0.0.0.dev5
3
+ Version: 0.0.0.dev7
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>
File without changes
File without changes
File without changes