gitbolt 0.0.0__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 +97 -0
- gitbolt/_internal_init.py +18 -0
- gitbolt/add.py +652 -0
- gitbolt/base.py +983 -0
- gitbolt/constants.py +12 -0
- gitbolt/exceptions.py +46 -0
- gitbolt/hash_object.py +263 -0
- gitbolt/ls_tree.py +155 -0
- gitbolt/models.py +698 -0
- gitbolt/py.typed +0 -0
- gitbolt/pytest_plugin.py +41 -0
- gitbolt/subprocess/__init__.py +18 -0
- gitbolt/subprocess/_internal_init.py +9 -0
- gitbolt/subprocess/add.py +484 -0
- gitbolt/subprocess/base.py +1835 -0
- gitbolt/subprocess/constants.py +23 -0
- gitbolt/subprocess/exceptions.py +110 -0
- gitbolt/subprocess/hash_object.py +227 -0
- gitbolt/subprocess/hash_object_util.py +90 -0
- gitbolt/subprocess/impl/__init__.py +6 -0
- gitbolt/subprocess/impl/simple.py +613 -0
- gitbolt/subprocess/ls_tree.py +406 -0
- gitbolt/subprocess/runner/__init__.py +8 -0
- gitbolt/subprocess/runner/base.py +106 -0
- gitbolt/subprocess/runner/simple.py +150 -0
- gitbolt/subprocess/utils/__init__.py +6 -0
- gitbolt/subprocess/utils/main_cmd.py +216 -0
- gitbolt/subprocess/utils/models.py +97 -0
- gitbolt/subprocess/utils/session.py +610 -0
- gitbolt/subprocess/worktree.py +266 -0
- gitbolt/utils.py +215 -0
- gitbolt-0.0.0.dist-info/METADATA +464 -0
- gitbolt-0.0.0.dist-info/RECORD +37 -0
- gitbolt-0.0.0.dist-info/WHEEL +5 -0
- gitbolt-0.0.0.dist-info/entry_points.txt +2 -0
- gitbolt-0.0.0.dist-info/licenses/LICENSE +201 -0
- gitbolt-0.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gitbolt
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Fast, flexible and type-safe Git commands in Python.
|
|
5
|
+
Author-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>, Thamotharan R <thamotharan.r@vaastav.tech>
|
|
6
|
+
Maintainer-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
Project-URL: homepage, https://github.com/Vaastav-Technologies/py-gitbolt
|
|
9
|
+
Project-URL: source, https://github.com/Vaastav-Technologies/py-gitbolt
|
|
10
|
+
Project-URL: issues, https://github.com/Vaastav-Technologies/py-gitbolt/issues
|
|
11
|
+
Keywords: git,vcs,library,version control
|
|
12
|
+
Classifier: Development Status :: 1 - Planning
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Education
|
|
15
|
+
Classifier: Topic :: Education
|
|
16
|
+
Classifier: Topic :: Software Development
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Classifier: Topic :: Software Development :: Version Control
|
|
20
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.12
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: vt-err-hndlr>=0.0.0dev6
|
|
30
|
+
Requires-Dist: vt-commons>=0.0.1.dev11
|
|
31
|
+
Provides-Extra: pygit2
|
|
32
|
+
Requires-Dist: pygit2; extra == "pygit2"
|
|
33
|
+
Provides-Extra: test
|
|
34
|
+
Requires-Dist: pytest; extra == "test"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# π Gitbolt
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+

|
|
41
|
+
[](https://github.com/Vaastav-Technologies/py-gitbolt/actions/workflows/test.yml)
|
|
42
|
+
[](https://github.com/Vaastav-Technologies/py-gitbolt/actions/workflows/typecheck.yml)
|
|
43
|
+
[](https://github.com/Vaastav-Technologies/py-gitbolt/actions/workflows/lint.yml)
|
|
44
|
+
[](https://codecov.io/gh/Vaastav-Technologies/py-gitbolt)
|
|
45
|
+
[](https://github.com/Vaastav-Technologies/py-gitbolt/actions/workflows/python-publish.yml)
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
**Fast, flexible and type-safe Git command execution in Python using subprocess.**
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## β¨ Features
|
|
53
|
+
|
|
54
|
+
* π§ **Typed:** All commands and options are statically type-checked.
|
|
55
|
+
* β‘ **Fast:** Minimal abstractions over subprocess, runs directly on your system Git.
|
|
56
|
+
* π§© **Composable:** Git commands and options can be passed around as objects.
|
|
57
|
+
* π **Overridable:** Easily override environment variables and options in a chainable, readable manner.
|
|
58
|
+
* π¦ **Lightweight:** No dependencies on heavy Git libraries or C extensions.
|
|
59
|
+
* π§° **Extensible:** Future support for output transformers and other plugins.
|
|
60
|
+
* π¨ **Exception Handling:** Raises any error as a Python-recognisable exception.
|
|
61
|
+
* π€ **Debuggable:** Exceptions capture `stdout`, `stderr`, and the return code of the run command.
|
|
62
|
+
* π€ **Lazy Execution:** Inherently lazily processed.
|
|
63
|
+
* π **Transparent Output:** Returns a Git command's `stdout` as-is.
|
|
64
|
+
* π§ͺ **Terminal Functions:** Git subcommands are terminal functions.
|
|
65
|
+
* π§Ό **Idiomatic Python:** Write commands in idiomatic Python at compile-time and be confident theyβll execute smoothly at runtime.
|
|
66
|
+
* π **Add-ons:** Special features provided to ease programming with git. These can be added if required.
|
|
67
|
+
* π» **CLI-cmd:** Take commands from cli and run in `gitbolt`.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## π¦ Installation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install gitbolt
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## π‘ Motivation
|
|
80
|
+
|
|
81
|
+
Running system commands in Python can be tricky for the following reasons:
|
|
82
|
+
|
|
83
|
+
1. Arguments sent to `subprocess` may not be typed correctly and result in runtime errors.
|
|
84
|
+
2. Argument groups may be mutually exclusive or required conditionally β again causing runtime issues.
|
|
85
|
+
3. Errors from subprocess are often unhelpful and difficult to debug.
|
|
86
|
+
|
|
87
|
+
Also, using subprocess effectively means you must:
|
|
88
|
+
|
|
89
|
+
* Understand and manage process setup, piping, and teardown.
|
|
90
|
+
* Know your CLI command intricacies in depth.
|
|
91
|
+
|
|
92
|
+
> This project exists to fix all that β with ergonomics, speed, and type-safety.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## π― Project Goals
|
|
97
|
+
|
|
98
|
+
### β
Predictable Compile-Time Behavior
|
|
99
|
+
|
|
100
|
+
Type-checking ensures runtime safety.
|
|
101
|
+
|
|
102
|
+
### β
Ergonomic APIs
|
|
103
|
+
|
|
104
|
+
<details>
|
|
105
|
+
<summary>Make git command interfaces as ergonomic to the user as possible.</summary>
|
|
106
|
+
|
|
107
|
+
#### Provide versions of most used command combinations
|
|
108
|
+
|
|
109
|
+
`git hash-object` supports taking multiple files and outputs a hash per file. But in practice, it's most often used to write a single file to the Git object database and return its hash. To match this real-world usage, Gitbolt offers a more ergonomic method that accepts one file and returns one hash β while still giving you the flexibility to access the full range of `git hash-object` capabilities when needed.
|
|
110
|
+
|
|
111
|
+
#### Let subcommands be passed around as objects
|
|
112
|
+
|
|
113
|
+
Gitbolt lets you pass subcommands around as typed objects. This enables highly focused, minimal APIs β you can write functions that accept only the subcommands they truly need. This leads to cleaner logic, better separation of concerns, and compile-time guarantees that help prevent misuse.
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
import gitbolt
|
|
117
|
+
|
|
118
|
+
git = gitbolt.get_git()
|
|
119
|
+
version_subcmd = git.version_subcmd()
|
|
120
|
+
add_subcmd = git.add_subcmd()
|
|
121
|
+
|
|
122
|
+
def method_which_only_adds_a_file(add_subcmd: gitbolt.base.Add):
|
|
123
|
+
"""
|
|
124
|
+
This method only requires the `add` subcommand.
|
|
125
|
+
"""
|
|
126
|
+
...
|
|
127
|
+
|
|
128
|
+
method_which_only_adds_a_file(add_subcmd)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
</details>
|
|
132
|
+
|
|
133
|
+
### β
Subcommands as Objects
|
|
134
|
+
|
|
135
|
+
git subcommands are modeled as terminal functions that return stdout.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
import gitbolt
|
|
139
|
+
|
|
140
|
+
git = gitbolt.get_git()
|
|
141
|
+
version_stdout = git.version_subcmd().version().version()
|
|
142
|
+
print(version_stdout)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### πͺΌ Modular Architecture
|
|
146
|
+
|
|
147
|
+
#### π§βπ» Modular at the programmatic level
|
|
148
|
+
|
|
149
|
+
Commands are designed to be passed around as objects. This makes them modular and thus users can opt to use only
|
|
150
|
+
particular commands.
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from gitbolt import get_git
|
|
154
|
+
|
|
155
|
+
git = get_git() # get git object for the current working directory
|
|
156
|
+
add_subcmd = git.add_subcmd()
|
|
157
|
+
ls_tree_subcmd = git.ls_tree_subcmd()
|
|
158
|
+
|
|
159
|
+
# now, functions can be written to accept only the required subcommands and nothing more than that.
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### π½οΈ Modular at project level
|
|
163
|
+
|
|
164
|
+
Only required commands and hence their implementations can be installed as per user requirement.
|
|
165
|
+
|
|
166
|
+
e.g.
|
|
167
|
+
|
|
168
|
+
- To install only the `git add` command related logic:
|
|
169
|
+
- ```shell
|
|
170
|
+
pip install gitbolt[add]
|
|
171
|
+
```
|
|
172
|
+
- To install command logic related to `git add` and `git rm` commands:
|
|
173
|
+
- ```shell
|
|
174
|
+
pip install gitbolt[add,rm]
|
|
175
|
+
```
|
|
176
|
+
- Install all porcelain related commands:
|
|
177
|
+
- ```shell
|
|
178
|
+
pip install gitbolt[porcelain]
|
|
179
|
+
```
|
|
180
|
+
- Install high performance `pygit2` implementations:
|
|
181
|
+
- ```shell
|
|
182
|
+
pip install gitbolt[pygit2]
|
|
183
|
+
```
|
|
184
|
+
- ```shell
|
|
185
|
+
pip install gitbolt[add,pygit2,rm]
|
|
186
|
+
```
|
|
187
|
+
- At last, install every command's implementation:
|
|
188
|
+
- ```shell
|
|
189
|
+
pip install gitbolt[all]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## π§ Strong Typing Everywhere
|
|
195
|
+
|
|
196
|
+
Extensive use of type-hints ensures that invalid usages fail early β at *compile-time*. Write at compile-time and be sure that commands run error-free at runtime.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary>Allow users to set/unset/reset Git environment variables and main command options using typed, chainable, Pythonic methods β just before a subcommand is executed.</summary>
|
|
202
|
+
|
|
203
|
+
### 𧬠Git Environment Variables
|
|
204
|
+
|
|
205
|
+
#### π Override a single Git env (e.g., `GIT_TRACE`)
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
import gitbolt
|
|
209
|
+
|
|
210
|
+
git = gitbolt.get_git()
|
|
211
|
+
git = git.git_envs_override(GIT_TRACE=True)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### π Override multiple Git envs (e.g., `GIT_TRACE`, `GIT_DIR`, `GIT_EDITOR`)
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
from pathlib import Path
|
|
218
|
+
import gitbolt
|
|
219
|
+
|
|
220
|
+
git = gitbolt.get_git()
|
|
221
|
+
git = git.git_envs_override(GIT_TRACE=1, GIT_DIR=Path('/tmp/git-dir/'), GIT_EDITOR='vim')
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### πͺ’ Chain multiple overrides fluently
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
from pathlib import Path
|
|
228
|
+
import gitbolt
|
|
229
|
+
|
|
230
|
+
git = gitbolt.get_git()
|
|
231
|
+
overridden_git = git.git_envs_override(GIT_SSH=Path('/tmp/SSH')).git_envs_override(
|
|
232
|
+
GIT_TERMINAL_PROMPT=1,
|
|
233
|
+
GIT_NO_REPLACE_OBJECTS=True
|
|
234
|
+
)
|
|
235
|
+
re_overridden_git = overridden_git.git_envs_override(GIT_TRACE=True)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### β Unset Git envs using a special `UNSET` marker
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
import gitbolt
|
|
242
|
+
from vt.utils.commons.commons.core_py import UNSET
|
|
243
|
+
|
|
244
|
+
git = gitbolt.get_git()
|
|
245
|
+
overridden_git = git.git_envs_override(GIT_ADVICE=True, GIT_TRACE=True)
|
|
246
|
+
no_advice_unset_git = overridden_git.git_envs_override(GIT_TRACE=UNSET)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### π Reset Git envs by setting new values
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
import gitbolt
|
|
253
|
+
|
|
254
|
+
git = gitbolt.get_git()
|
|
255
|
+
overridden_git = git.git_envs_override(GIT_TRACE=True)
|
|
256
|
+
git_trace_reset_git = overridden_git.git_envs_override(GIT_TRACE=False)
|
|
257
|
+
```
|
|
258
|
+
</details>
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
<details>
|
|
263
|
+
<summary>Allow users to set/unset/reset git main command options in typed and pythonic manner just before subcommand run to provide maximal flexibility.</summary>
|
|
264
|
+
|
|
265
|
+
### βοΈ Git Main Command Options
|
|
266
|
+
|
|
267
|
+
#### π Override a single Git opt (e.g., `--no-replace-objects`)
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
import gitbolt
|
|
271
|
+
|
|
272
|
+
git = gitbolt.get_git()
|
|
273
|
+
git = git.git_opts_override(no_replace_objects=True)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### π Override multiple options (e.g., `--git-dir`, `--paginate`)
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
from pathlib import Path
|
|
280
|
+
from gitbolt.subprocess.impl.simple import SimpleGitCommand
|
|
281
|
+
|
|
282
|
+
git = SimpleGitCommand()
|
|
283
|
+
git = git.git_opts_override(no_replace_objects=True, git_dir=Path(), paginate=True)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### πͺ’ Chain multiple option overrides fluently
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
import gitbolt
|
|
290
|
+
from pathlib import Path
|
|
291
|
+
|
|
292
|
+
git = gitbolt.get_git()
|
|
293
|
+
overridden_git = git.git_opts_override(exec_path=Path('tmp')).git_opts_override(
|
|
294
|
+
noglob_pathspecs=True,
|
|
295
|
+
no_advice=True
|
|
296
|
+
).git_opts_override(
|
|
297
|
+
config_env={'auth': 'suhas', 'comm': 'suyog'}
|
|
298
|
+
)
|
|
299
|
+
re_overridden_git = overridden_git.git_opts_override(glob_pathspecs=True)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
#### β Unset Git opts using a special `UNSET` marker
|
|
303
|
+
|
|
304
|
+
```python
|
|
305
|
+
import gitbolt
|
|
306
|
+
from pathlib import Path
|
|
307
|
+
from vt.utils.commons.commons.core_py import UNSET
|
|
308
|
+
|
|
309
|
+
git = gitbolt.get_git()
|
|
310
|
+
overridden_git = git.git_opts_override(exec_path=Path('tmp'), no_advice=True)
|
|
311
|
+
no_advice_unset_git = overridden_git.git_opts_override(no_advice=UNSET)
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
#### π Reset Git opts by setting new values
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
import gitbolt
|
|
318
|
+
|
|
319
|
+
git = gitbolt.get_git()
|
|
320
|
+
overridden_git = git.git_opts_override(no_advice=True)
|
|
321
|
+
no_advice_reset_git = overridden_git.git_opts_override(no_advice=False)
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
</details>
|
|
325
|
+
|
|
326
|
+
### π Run unchecked commands
|
|
327
|
+
|
|
328
|
+
At last, run unchecked commands in git.
|
|
329
|
+
|
|
330
|
+
Introduced in `0.0.0.dev4` to
|
|
331
|
+
- experiment.
|
|
332
|
+
- have consistent interfaced commands run until all subcommands are provided by the library.
|
|
333
|
+
|
|
334
|
+
#### π₯οΈ Run one process per command
|
|
335
|
+
|
|
336
|
+
```python
|
|
337
|
+
import gitbolt
|
|
338
|
+
|
|
339
|
+
git = gitbolt.get_git_command()
|
|
340
|
+
git = git.git_opts_override(no_advice=True)
|
|
341
|
+
git.subcmd_unchecked().run(['--version']) # run the version option for git.
|
|
342
|
+
git.subcmd_unchecked().run(['version']) # run the version subcommand.
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
#### π₯οΈ Run one long-running process and communicate with it
|
|
346
|
+
|
|
347
|
+
Introduced in `0.0.0.dev16` to:
|
|
348
|
+
- Make communicable processes using `subprocess.Popen`.
|
|
349
|
+
|
|
350
|
+
Get a long-running process and communicate with it for batching and faster operations.
|
|
351
|
+
|
|
352
|
+
```python
|
|
353
|
+
import gitbolt
|
|
354
|
+
import sys
|
|
355
|
+
|
|
356
|
+
git = gitbolt.get_git_command()
|
|
357
|
+
with git.subcmd_unchecked().popen(["cat-file", "--batch-command"]) as cf:
|
|
358
|
+
cf.stdin.write(b"contents HEAD\n")
|
|
359
|
+
cf.stdin.flush()
|
|
360
|
+
header = cf.stdout.readline().strip()
|
|
361
|
+
print(f"HEADER: {header}", file=sys.stderr)
|
|
362
|
+
obj, typ, size = header.split()
|
|
363
|
+
print(cf.stdout.read(int(size)))
|
|
364
|
+
cf.stdout.readline()
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Error handling and I/O management is left to the client/caller.
|
|
368
|
+
|
|
369
|
+
#### π Communicate with long-running git sessions
|
|
370
|
+
|
|
371
|
+
Introduced in `0.0.0.dev17` to:
|
|
372
|
+
- Make long-running git command sessions.
|
|
373
|
+
- Have reentrant sessions.
|
|
374
|
+
- Communicate with long-running git command session using their `stdin` and `stdout`.
|
|
375
|
+
|
|
376
|
+
Get long-running process sessions and communicate with them for batching and faster operations.
|
|
377
|
+
|
|
378
|
+
```python
|
|
379
|
+
import gitbolt
|
|
380
|
+
from gitbolt.subprocess.utils.session import cat_file_blob_content, cat_file_tree_data, cat_file_tree_content, \
|
|
381
|
+
mktree_tree_make
|
|
382
|
+
|
|
383
|
+
git = gitbolt.get_git_command()
|
|
384
|
+
with git.session(
|
|
385
|
+
cat_file1=["cat-file", "--batch"],
|
|
386
|
+
cat_file2=["cat-file", "--batch"],
|
|
387
|
+
cat_file3=lambda: git.subcmd_unchecked().popen(["cat-file", "--batch"]), # pass your own git subcmd Popen(s)
|
|
388
|
+
mktree=["mktree", "--batch", "-z"]
|
|
389
|
+
) as ses: # reusable and reentrant session
|
|
390
|
+
tree_data: list[bytes] = []
|
|
391
|
+
for mode_, sha_, name_ in cat_file_tree_data(ses.commands.cat_file2, b"HEAD^{tree}"):
|
|
392
|
+
print(mode_, sha_, name_)
|
|
393
|
+
for tree_entry in cat_file_tree_content(ses.commands.cat_file2, b"HEAD^{tree}"):
|
|
394
|
+
tree_data.append(tree_entry)
|
|
395
|
+
print("+" * 40)
|
|
396
|
+
print(cat_file_blob_content(ses.commands.cat_file3, b"9854cb4d432a881f59d38582791cf2636e7819d9"))
|
|
397
|
+
print("~" * 40)
|
|
398
|
+
with ses: # is reentrant, if you want
|
|
399
|
+
tree_hash = mktree_tree_make(ses.commands.mktree, b"\0".join(tree_data)) # make tree
|
|
400
|
+
print("Obtained tree: ", tree_hash)
|
|
401
|
+
|
|
402
|
+
assert not ses.active # session no long active
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
#### π» Run commands received from CLI
|
|
406
|
+
|
|
407
|
+
Introduced in `0.0.0.dev11` is the ability to take commands from CLI and run it inside `gitbolt`.
|
|
408
|
+
|
|
409
|
+
While making a system it may be required to run cli commands as received from cli using gitbolt. An obvious example
|
|
410
|
+
would be to make a system that receives CLI commands and does certain modifications/additions inside `gitbolt` before
|
|
411
|
+
actually running them. An example:
|
|
412
|
+
|
|
413
|
+
```python
|
|
414
|
+
import gitbolt
|
|
415
|
+
|
|
416
|
+
opts = ["--no-pager", "--namespace", "n1"] # options received from outside your program.
|
|
417
|
+
envs = dict(GIT_AUTHOR_NAME="ss") # env-vars received form outside your program.
|
|
418
|
+
git = gitbolt.get_git_command(opts=opts, envs=envs)
|
|
419
|
+
|
|
420
|
+
# these can later be overridden
|
|
421
|
+
git = git.git_opts_override(namespace="n2")
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## π Transparent by Default
|
|
427
|
+
|
|
428
|
+
Output of git commands is returned as-is. No transformations unless explicitly requested.
|
|
429
|
+
Transformers for formatting/parsing can be added later.
|
|
430
|
+
|
|
431
|
+
---
|
|
432
|
+
|
|
433
|
+
## Notes
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
- 0.0.0.dev24: `worktree` implementations are not stable yet. Use `subcmd_unchecked` directly.
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## β
Benefits Out-of-the-Box
|
|
441
|
+
|
|
442
|
+
* π Composable Git commands.
|
|
443
|
+
* π€ Returns raw stdout.
|
|
444
|
+
* π¨ Exceptions with full context.
|
|
445
|
+
* π€ Lazy execution.
|
|
446
|
+
* π§ Strong typing and compile-time guarantees.
|
|
447
|
+
* π§Ό Idiomatic Python.
|
|
448
|
+
* π§ͺ Terminal subcommands.
|
|
449
|
+
* π£ Fail-fast on invalid usage.
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## π More Information
|
|
454
|
+
|
|
455
|
+
- π [License (Apache-2.0)](./LICENSE)
|
|
456
|
+
- π€ [Contributing Guide](./CONTRIBUTING.md)
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## π§ Future Goals
|
|
461
|
+
|
|
462
|
+
* Support `pygit2` for direct, fast Git access.
|
|
463
|
+
* Enable `porcelain` support using `pygit2` where required.
|
|
464
|
+
> `pygit2` usage will automatically make all commands return in porcelain mode.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
gitbolt/__init__.py,sha256=G66SCSLs9mNx26i0wVvFiN9UAELWnZqpDvZHme9ntnY,3702
|
|
2
|
+
gitbolt/_internal_init.py,sha256=alSsIMgBWHmOdUo7P1ewftR12xPv8vb3ZgECuVsRMwk,485
|
|
3
|
+
gitbolt/add.py,sha256=F16d0SQfLrjbpUzJIjKFwGU4KLSjqtYLOA9oZ5gdNS0,31731
|
|
4
|
+
gitbolt/base.py,sha256=OXQqyVFihQUxuwa3kfYwM_a5I8WQYYLGH6ko2sWqo5k,35383
|
|
5
|
+
gitbolt/constants.py,sha256=DTdG44PiJ-2XbScPcvvUOMGVDjddH-j7pORO42fjgiE,206
|
|
6
|
+
gitbolt/exceptions.py,sha256=7YvR7whZYM1hlWZk4GxHbeNgJ0KJXElg5VFA1Vi-fiA,989
|
|
7
|
+
gitbolt/hash_object.py,sha256=VGATf87b1uEpW327C9tVKSbIEnm67yf8kIwbpXv65gg,10917
|
|
8
|
+
gitbolt/ls_tree.py,sha256=PrDSoh4Pnqh6g4AfX8kwgez_zHYaH4yqknULbFbisUY,6269
|
|
9
|
+
gitbolt/models.py,sha256=ExIYraiqD_WlwouUady0UtnZ8Vi9FlkzOZkWoCmOMz4,19040
|
|
10
|
+
gitbolt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
gitbolt/pytest_plugin.py,sha256=Gto30Ofmfz8kJ_AuBrEhqENmWoDlpMnsrpQWzHDmUi4,833
|
|
12
|
+
gitbolt/utils.py,sha256=GGD1XBj0lQ8Z1ygItZl-k69fyrxQGzeID15f3yiWzGc,7275
|
|
13
|
+
gitbolt/subprocess/__init__.py,sha256=hvHxx6pV7je3csTkLOWvN4Q4081CUQJ1UEsYmmdz23o,787
|
|
14
|
+
gitbolt/subprocess/_internal_init.py,sha256=C6jfsbjXhIFHaDH9GE-wLPAN9WMlUU57rRLWvfpZuAs,255
|
|
15
|
+
gitbolt/subprocess/add.py,sha256=EDBEbBaVvxAkk3jAfrVAKSuwhln8uJiv-Tq0Pc5kuig,17273
|
|
16
|
+
gitbolt/subprocess/base.py,sha256=aJ_7b501LwiZPqboqCNtpOM9iFDvGPNyr7tTnNEmfmc,63975
|
|
17
|
+
gitbolt/subprocess/constants.py,sha256=Zxz-bfAmDyDu5ieI0fFzjygfPzgr6PJCKCHAj3g_ctc,656
|
|
18
|
+
gitbolt/subprocess/exceptions.py,sha256=xLqkKPnya0O-N12sxfQDX9YQZilgDj-OOAT09lYrjrY,4043
|
|
19
|
+
gitbolt/subprocess/hash_object.py,sha256=JnPbR-W9yIBcc-rO51RTMtCQV71XK-S4jgUE4ExKD-E,7554
|
|
20
|
+
gitbolt/subprocess/hash_object_util.py,sha256=GVkZw3cCro0TB_WjfJxhFSma5hocaEEdIPbeSUXjFyQ,2621
|
|
21
|
+
gitbolt/subprocess/ls_tree.py,sha256=qn17b4S-xvzyMoOtgrt7FDzf3eiLMLNG6wAwfsz9SsE,14672
|
|
22
|
+
gitbolt/subprocess/worktree.py,sha256=K2KBLvnIquSqptiG-YTdUSvo76PA8Rfz3P4boFWHV0A,11078
|
|
23
|
+
gitbolt/subprocess/impl/__init__.py,sha256=bxYluO0B3My-10H5Z0JuEGvZe_g8i71QTpt6iM0WXoU,97
|
|
24
|
+
gitbolt/subprocess/impl/simple.py,sha256=s4Lk1WAj81ds8HFsUag4PlopOcvS-xMzmi0JShMsN4M,23523
|
|
25
|
+
gitbolt/subprocess/runner/__init__.py,sha256=_azhx53v4i4uF6Z8Tpu1h1-7hHDiyEqnaD0-W414QSM,173
|
|
26
|
+
gitbolt/subprocess/runner/base.py,sha256=Vczn-7Jj2Sl1b8uQJkVU2rACrxmp0iUamtUcQEf0xSM,2711
|
|
27
|
+
gitbolt/subprocess/runner/simple.py,sha256=PifHmEx754mrOIQkBA9XvjUqZPPN_dwMPbwM7nfxguM,4234
|
|
28
|
+
gitbolt/subprocess/utils/__init__.py,sha256=Xk4jM1i8WsozSWnpxS5SFAICyqGitpCBArhYWVXCjP4,122
|
|
29
|
+
gitbolt/subprocess/utils/main_cmd.py,sha256=xB9fkdzNYCz7u5-83grlrr9VF-CaJc39CManZCu_L_E,6373
|
|
30
|
+
gitbolt/subprocess/utils/models.py,sha256=-wBjtHoxMNlZLLr_Ggjn4Jt5FQ6-sdnyRXKxHKIITcE,3216
|
|
31
|
+
gitbolt/subprocess/utils/session.py,sha256=6SZHk08eZ8_hRXepiYAAVUWrGgYMiA_rJd4ESFqQ4fo,31315
|
|
32
|
+
gitbolt-0.0.0.dist-info/licenses/LICENSE,sha256=pOzr5bMWS6mHi3vro8d5vw0qW1i14rVq2XFrDuystVY,11372
|
|
33
|
+
gitbolt-0.0.0.dist-info/METADATA,sha256=TAKDAkDbV4VYftAZ_kCcWjkfKLe47wAa8KrW788GqYc,15374
|
|
34
|
+
gitbolt-0.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
35
|
+
gitbolt-0.0.0.dist-info/entry_points.txt,sha256=Q078Wjss4skreUs8hzAEJ8sUcH4Rhjc9emZ4jRXCiBM,52
|
|
36
|
+
gitbolt-0.0.0.dist-info/top_level.txt,sha256=QCXclkzSPZjgamcwB6XuKJexaJ1as_TLUUSGdIDA7VY,8
|
|
37
|
+
gitbolt-0.0.0.dist-info/RECORD,,
|