gitbolt 0.0.0.dev2__py3-none-any.whl → 0.0.0.dev4__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.
- gitbolt/__init__.py +3 -0
- gitbolt/constants.py +10 -0
- gitbolt/git_subprocess/__init__.py +1 -0
- gitbolt/git_subprocess/base.py +101 -1
- gitbolt/git_subprocess/impl/simple.py +27 -0
- gitbolt/git_subprocess/runner/simple_impl.py +1 -1
- {gitbolt-0.0.0.dev2.dist-info → gitbolt-0.0.0.dev4.dist-info}/METADATA +18 -1
- {gitbolt-0.0.0.dev2.dist-info → gitbolt-0.0.0.dev4.dist-info}/RECORD +11 -10
- {gitbolt-0.0.0.dev2.dist-info → gitbolt-0.0.0.dev4.dist-info}/WHEEL +0 -0
- {gitbolt-0.0.0.dev2.dist-info → gitbolt-0.0.0.dev4.dist-info}/licenses/LICENSE +0 -0
- {gitbolt-0.0.0.dev2.dist-info → gitbolt-0.0.0.dev4.dist-info}/top_level.txt +0 -0
gitbolt/__init__.py
CHANGED
gitbolt/constants.py
ADDED
|
@@ -11,4 +11,5 @@ from gitbolt.git_subprocess.base import GitSubcmdCommand as GitSubcmdCommand
|
|
|
11
11
|
from gitbolt.git_subprocess.base import AddCommand as AddCommand
|
|
12
12
|
from gitbolt.git_subprocess.base import LsTreeCommand as LsTreeCommand
|
|
13
13
|
from gitbolt.git_subprocess.base import VersionCommand as VersionCommand
|
|
14
|
+
from gitbolt.git_subprocess.base import UncheckedSubcmd as UncheckedSubcmd
|
|
14
15
|
# endregion
|
gitbolt/git_subprocess/base.py
CHANGED
|
@@ -9,9 +9,11 @@ from __future__ import annotations
|
|
|
9
9
|
|
|
10
10
|
from abc import abstractmethod, ABC
|
|
11
11
|
from pathlib import Path
|
|
12
|
-
from
|
|
12
|
+
from subprocess import CompletedProcess
|
|
13
|
+
from typing import override, Protocol, Unpack, Self, overload, Literal, Any
|
|
13
14
|
|
|
14
15
|
from vt.utils.commons.commons.core_py import is_unset, not_none_not_unset
|
|
16
|
+
from vt.utils.commons.commons.op import RootDirOp
|
|
15
17
|
|
|
16
18
|
from gitbolt import Git, Version, LsTree, GitSubCommand, HasGitUnderneath, Add
|
|
17
19
|
from gitbolt.git_subprocess.add import AddCLIArgsBuilder, IndividuallyOverridableACAB
|
|
@@ -283,6 +285,14 @@ class GitCommand(Git, ABC):
|
|
|
283
285
|
@abstractmethod
|
|
284
286
|
def add_subcmd(self) -> AddCommand: ...
|
|
285
287
|
|
|
288
|
+
@property
|
|
289
|
+
@abstractmethod
|
|
290
|
+
def subcmd_unchecked(self) -> UncheckedSubcmd:
|
|
291
|
+
"""
|
|
292
|
+
Run an unchecked git subcommand using subprocess.
|
|
293
|
+
"""
|
|
294
|
+
...
|
|
295
|
+
|
|
286
296
|
|
|
287
297
|
class GitSubcmdCommand(GitSubCommand, HasGitUnderneath["GitCommand"], Protocol):
|
|
288
298
|
"""
|
|
@@ -434,3 +444,93 @@ class AddCommand(Add, GitSubcmdCommand, Protocol):
|
|
|
434
444
|
:return: Builder the complete list of subcommand CLI arguments to be passed to ``git add`` subprocess.
|
|
435
445
|
"""
|
|
436
446
|
return IndividuallyOverridableACAB()
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
class UncheckedSubcmd(GitSubcmdCommand, RootDirOp, Protocol):
|
|
450
|
+
"""
|
|
451
|
+
Unchecked git subcommand. Runs subcommands directly in subprocess.
|
|
452
|
+
"""
|
|
453
|
+
|
|
454
|
+
@override
|
|
455
|
+
def _subcmd_from_git(self, git: "Git") -> Self:
|
|
456
|
+
return self
|
|
457
|
+
|
|
458
|
+
@overload
|
|
459
|
+
def run(
|
|
460
|
+
self,
|
|
461
|
+
subcommand_args: list[str],
|
|
462
|
+
*subprocess_run_args: Any,
|
|
463
|
+
_input: str,
|
|
464
|
+
text: Literal[True],
|
|
465
|
+
**subprocess_run_kwargs: Any,
|
|
466
|
+
) -> CompletedProcess[str]: ...
|
|
467
|
+
|
|
468
|
+
@overload
|
|
469
|
+
def run(
|
|
470
|
+
self,
|
|
471
|
+
subcommand_args: list[str],
|
|
472
|
+
*subprocess_run_args: Any,
|
|
473
|
+
_input: bytes,
|
|
474
|
+
text: Literal[False],
|
|
475
|
+
**subprocess_run_kwargs: Any,
|
|
476
|
+
) -> CompletedProcess[bytes]: ...
|
|
477
|
+
|
|
478
|
+
@overload
|
|
479
|
+
def run(
|
|
480
|
+
self,
|
|
481
|
+
subcommand_args: list[str],
|
|
482
|
+
*subprocess_run_args: Any,
|
|
483
|
+
text: Literal[True],
|
|
484
|
+
**subprocess_run_kwargs: Any,
|
|
485
|
+
) -> CompletedProcess[str]: ...
|
|
486
|
+
|
|
487
|
+
@overload
|
|
488
|
+
def run(
|
|
489
|
+
self,
|
|
490
|
+
subcommand_args: list[str],
|
|
491
|
+
*subprocess_run_args: Any,
|
|
492
|
+
text: Literal[False] = ...,
|
|
493
|
+
**subprocess_run_kwargs: Any,
|
|
494
|
+
) -> CompletedProcess[bytes]: ...
|
|
495
|
+
|
|
496
|
+
def run(
|
|
497
|
+
self,
|
|
498
|
+
subcommand_args: list[str],
|
|
499
|
+
*subprocess_run_args: Any,
|
|
500
|
+
_input: str | bytes | None = None,
|
|
501
|
+
text: Literal[True, False] = False,
|
|
502
|
+
**subprocess_run_kwargs,
|
|
503
|
+
) -> CompletedProcess[str] | CompletedProcess[bytes]:
|
|
504
|
+
"""
|
|
505
|
+
Run unchecked git subcommand using subprocess
|
|
506
|
+
|
|
507
|
+
:param subcommand_args: the full subcommand argument list.
|
|
508
|
+
:param subprocess_run_args: additional subprocess positionals.
|
|
509
|
+
:param _input: any stdin to be passed to the subprocess.
|
|
510
|
+
:param text: ``_input`` and returns both are str if this value is ``True``. Else, bytes are considered.
|
|
511
|
+
:param subprocess_run_kwargs: additional subprocess keyword arguments.
|
|
512
|
+
|
|
513
|
+
:return: ``CompletedProcess`` capturing all the required stdout, stderr, return-code etc.
|
|
514
|
+
"""
|
|
515
|
+
main_cmd_args = self.underlying_git.build_main_cmd_args()
|
|
516
|
+
envs_vars = self.underlying_git.build_git_envs()
|
|
517
|
+
another_supplied_env = subprocess_run_kwargs.pop('env', None)
|
|
518
|
+
if another_supplied_env:
|
|
519
|
+
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
|
|
523
|
+
# Run the git command
|
|
524
|
+
result = self.underlying_git.runner.run_git_command(
|
|
525
|
+
main_cmd_args,
|
|
526
|
+
subcommand_args,
|
|
527
|
+
*subprocess_run_args,
|
|
528
|
+
_input=_input,
|
|
529
|
+
text=text,
|
|
530
|
+
env=envs_vars,
|
|
531
|
+
cwd=cwd,
|
|
532
|
+
capture_output=capture_output,
|
|
533
|
+
check=check,
|
|
534
|
+
**subprocess_run_kwargs
|
|
535
|
+
)
|
|
536
|
+
return result
|
|
@@ -20,6 +20,7 @@ from gitbolt.git_subprocess import (
|
|
|
20
20
|
LsTreeCommand,
|
|
21
21
|
GitSubcmdCommand,
|
|
22
22
|
AddCommand,
|
|
23
|
+
UncheckedSubcmd
|
|
23
24
|
)
|
|
24
25
|
from gitbolt.git_subprocess.add import AddCLIArgsBuilder
|
|
25
26
|
from gitbolt.git_subprocess.constants import VERSION_CMD
|
|
@@ -131,7 +132,26 @@ class AddCommandImpl(AddCommand, GitSubcmdCommandImpl):
|
|
|
131
132
|
return AddCommandImpl(self.root_dir, self.underlying_git)
|
|
132
133
|
|
|
133
134
|
|
|
135
|
+
class UncheckedSubcmdImpl(UncheckedSubcmd, GitSubcmdCommandImpl):
|
|
136
|
+
def __init__(
|
|
137
|
+
self,
|
|
138
|
+
root_dir: Path,
|
|
139
|
+
git: GitCommand
|
|
140
|
+
):
|
|
141
|
+
super().__init__(git)
|
|
142
|
+
self._root_dir = root_dir
|
|
143
|
+
|
|
144
|
+
@override
|
|
145
|
+
@property
|
|
146
|
+
def root_dir(self) -> Path:
|
|
147
|
+
return self._root_dir
|
|
148
|
+
|
|
149
|
+
def clone(self) -> "UncheckedSubcmdImpl":
|
|
150
|
+
return UncheckedSubcmdImpl(self.root_dir, self.underlying_git)
|
|
151
|
+
|
|
152
|
+
|
|
134
153
|
class SimpleGitCommand(GitCommand, RootDirOp):
|
|
154
|
+
|
|
135
155
|
def __init__(
|
|
136
156
|
self,
|
|
137
157
|
git_root_dir: Path = Path.cwd(),
|
|
@@ -140,12 +160,14 @@ class SimpleGitCommand(GitCommand, RootDirOp):
|
|
|
140
160
|
version_subcmd: VersionCommand | None = None,
|
|
141
161
|
ls_tree_subcmd: LsTreeCommand | None = None,
|
|
142
162
|
add_subcmd: AddCommand | None = None,
|
|
163
|
+
subcmd_unchecked: UncheckedSubcmd | None = None
|
|
143
164
|
):
|
|
144
165
|
super().__init__(runner)
|
|
145
166
|
self.git_root_dir = git_root_dir
|
|
146
167
|
self._version_subcmd = version_subcmd or VersionCommandImpl(self)
|
|
147
168
|
self._ls_tree = ls_tree_subcmd or LsTreeCommandImpl(self.root_dir, self)
|
|
148
169
|
self._add_subcmd = add_subcmd or AddCommandImpl(self.root_dir, self)
|
|
170
|
+
self._subcmd_unchecked = subcmd_unchecked or UncheckedSubcmdImpl(self.root_dir, self)
|
|
149
171
|
|
|
150
172
|
@override
|
|
151
173
|
@property
|
|
@@ -171,6 +193,7 @@ class SimpleGitCommand(GitCommand, RootDirOp):
|
|
|
171
193
|
version_subcmd=self.version_subcmd,
|
|
172
194
|
ls_tree_subcmd=self.ls_tree_subcmd,
|
|
173
195
|
add_subcmd=self.add_subcmd,
|
|
196
|
+
subcmd_unchecked=self.subcmd_unchecked
|
|
174
197
|
)
|
|
175
198
|
# endregion
|
|
176
199
|
# region clone protected members
|
|
@@ -183,3 +206,7 @@ class SimpleGitCommand(GitCommand, RootDirOp):
|
|
|
183
206
|
@property
|
|
184
207
|
def root_dir(self) -> Path:
|
|
185
208
|
return self.git_root_dir
|
|
209
|
+
|
|
210
|
+
@property
|
|
211
|
+
def subcmd_unchecked(self) -> UncheckedSubcmd:
|
|
212
|
+
return self._subcmd_unchecked
|
|
@@ -86,4 +86,4 @@ class SimpleGitCR(GitCommandRunner):
|
|
|
86
86
|
**subprocess_run_kwargs,
|
|
87
87
|
)
|
|
88
88
|
except subprocess.CalledProcessError as e:
|
|
89
|
-
raise GitCmdException(called_process_error=e, exit_code=e.returncode) from e
|
|
89
|
+
raise GitCmdException(e.stderr, called_process_error=e, exit_code=e.returncode) from e
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitbolt
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev4
|
|
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>
|
|
@@ -272,6 +272,23 @@ no_advice_reset_git = overridden_git.git_opts_override(no_advice=False)
|
|
|
272
272
|
|
|
273
273
|
</details>
|
|
274
274
|
|
|
275
|
+
### 🔄 Run unchecked commands
|
|
276
|
+
|
|
277
|
+
At last, run unchecked commands in git.
|
|
278
|
+
|
|
279
|
+
Introduced in `0.0.0dev4` to
|
|
280
|
+
- experiment.
|
|
281
|
+
- have consistent interfaced commands run until all subcommands are provided by the library.
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
|
|
285
|
+
|
|
286
|
+
git = SimpleGitCommand()
|
|
287
|
+
git = git.git_opts_override(no_advice=True)
|
|
288
|
+
git.subcmd_unchecked.run(['--version']) # run the version option for git.
|
|
289
|
+
git.subcmd_unchecked.run(['version']) # run the version subcommand.
|
|
290
|
+
```
|
|
291
|
+
|
|
275
292
|
|
|
276
293
|
---
|
|
277
294
|
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
gitbolt/__init__.py,sha256=
|
|
1
|
+
gitbolt/__init__.py,sha256=fYw-eNfs7kpowyQOqx0K8rmoMCCg4pZnxrBFrmHvIfM,1174
|
|
2
2
|
gitbolt/_internal_init.py,sha256=alSsIMgBWHmOdUo7P1ewftR12xPv8vb3ZgECuVsRMwk,485
|
|
3
3
|
gitbolt/add.py,sha256=F16d0SQfLrjbpUzJIjKFwGU4KLSjqtYLOA9oZ5gdNS0,31731
|
|
4
4
|
gitbolt/base.py,sha256=eUjzfu0OilCrOpxpwRyCSs7HD83OaXk6BCzxT8LKKhU,9322
|
|
5
|
+
gitbolt/constants.py,sha256=5obkhMs8Og9P_xxQKEPvDx0io9mIYhZLc8Uv2WVrOHI,152
|
|
5
6
|
gitbolt/exceptions.py,sha256=7YvR7whZYM1hlWZk4GxHbeNgJ0KJXElg5VFA1Vi-fiA,989
|
|
6
7
|
gitbolt/ls_tree.py,sha256=PrDSoh4Pnqh6g4AfX8kwgez_zHYaH4yqknULbFbisUY,6269
|
|
7
8
|
gitbolt/models.py,sha256=iwIO-ugHYiKS57I_LPo3uDFEQlAtu2mnn5AjZHHQg04,18828
|
|
8
9
|
gitbolt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
10
|
gitbolt/utils.py,sha256=XftX3LIKtfzjQaUZUF3QYaFJFM-QdFjc05ZrZSMSdeM,6315
|
|
10
|
-
gitbolt/git_subprocess/__init__.py,sha256=
|
|
11
|
+
gitbolt/git_subprocess/__init__.py,sha256=yEyJKH_iXFBkdgQMwE8vnHnhVTrjs2RkQUjUCF25SzU,590
|
|
11
12
|
gitbolt/git_subprocess/_internal_init.py,sha256=C6jfsbjXhIFHaDH9GE-wLPAN9WMlUU57rRLWvfpZuAs,255
|
|
12
13
|
gitbolt/git_subprocess/add.py,sha256=1PA9XonqFi2O941eBwIPMobSNgEJ0tgFYxlkVXSe1K4,17277
|
|
13
|
-
gitbolt/git_subprocess/base.py,sha256=
|
|
14
|
+
gitbolt/git_subprocess/base.py,sha256=ywm_bGVt0R9ILyj5rtwYS3e-gQGIkaGSGkaPvm1JK9k,17591
|
|
14
15
|
gitbolt/git_subprocess/constants.py,sha256=3qHXbNjPf_DOhTPNHi3_bcvIpvtqvgFtpGoTJLYmTWk,250
|
|
15
16
|
gitbolt/git_subprocess/exceptions.py,sha256=cx4YKzxeBRSRKoF-oakZLpFUGrAHiGj1FtMIsiK5oHc,4063
|
|
16
17
|
gitbolt/git_subprocess/ls_tree.py,sha256=MmM3qh-kvkD_tGQG9yliLx-reY_5TIVEArvAXJN6rP4,13200
|
|
17
18
|
gitbolt/git_subprocess/utils.py,sha256=n9_kXPvDf0ACrzAm6SVVLBOFM1JyjHmXJl_99vBoPS8,4941
|
|
18
19
|
gitbolt/git_subprocess/impl/__init__.py,sha256=bxYluO0B3My-10H5Z0JuEGvZe_g8i71QTpt6iM0WXoU,97
|
|
19
|
-
gitbolt/git_subprocess/impl/simple.py,sha256=
|
|
20
|
+
gitbolt/git_subprocess/impl/simple.py,sha256=yY7tMI4B093ssooZB4UvffVQaCrFVD1bAIrieYPajLQ,6407
|
|
20
21
|
gitbolt/git_subprocess/runner/__init__.py,sha256=LPxbj3AwKLXyDxxCLwAVtl5b5SKjaNDj99lkKz6VSOU,177
|
|
21
22
|
gitbolt/git_subprocess/runner/base.py,sha256=Sof2WaNyYULiObRF7WjaGs7-yGrdyeHUXchE2tg1820,1562
|
|
22
|
-
gitbolt/git_subprocess/runner/simple_impl.py,sha256=
|
|
23
|
-
gitbolt-0.0.0.
|
|
24
|
-
gitbolt-0.0.0.
|
|
25
|
-
gitbolt-0.0.0.
|
|
26
|
-
gitbolt-0.0.0.
|
|
27
|
-
gitbolt-0.0.0.
|
|
23
|
+
gitbolt/git_subprocess/runner/simple_impl.py,sha256=V-6efvcQLP6gpUKSwRfnNI-Zd9nBxaN0EuAnpn-5LwU,2494
|
|
24
|
+
gitbolt-0.0.0.dev4.dist-info/licenses/LICENSE,sha256=pOzr5bMWS6mHi3vro8d5vw0qW1i14rVq2XFrDuystVY,11372
|
|
25
|
+
gitbolt-0.0.0.dev4.dist-info/METADATA,sha256=JsZQi3otwuW43nJQ-Szj-lo99zBjmjYDAD7jaIYBP7M,11227
|
|
26
|
+
gitbolt-0.0.0.dev4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
27
|
+
gitbolt-0.0.0.dev4.dist-info/top_level.txt,sha256=QCXclkzSPZjgamcwB6XuKJexaJ1as_TLUUSGdIDA7VY,8
|
|
28
|
+
gitbolt-0.0.0.dev4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|