gitbolt 0.0.0.dev13__tar.gz → 0.0.0.dev15__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.dev13 → gitbolt-0.0.0.dev15}/PKG-INFO +32 -33
  2. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/README.md +30 -31
  3. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/pyproject.toml +2 -2
  4. gitbolt-0.0.0.dev15/src/gitbolt/__init__.py +96 -0
  5. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/base.py +5 -13
  6. gitbolt-0.0.0.dev15/src/gitbolt/subprocess/__init__.py +15 -0
  7. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/add.py +1 -1
  8. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/base.py +14 -14
  9. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/exceptions.py +5 -5
  10. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/impl/simple.py +16 -16
  11. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/ls_tree.py +1 -1
  12. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/runner/__init__.py +1 -1
  13. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/runner/base.py +9 -0
  14. gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess/runner/simple_impl.py → gitbolt-0.0.0.dev15/src/gitbolt/subprocess/runner/simple.py +16 -4
  15. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt.egg-info/PKG-INFO +32 -33
  16. gitbolt-0.0.0.dev15/src/gitbolt.egg-info/SOURCES.txt +33 -0
  17. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt.egg-info/requires.txt +1 -1
  18. gitbolt-0.0.0.dev13/src/gitbolt/__init__.py +0 -43
  19. gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess/__init__.py +0 -15
  20. gitbolt-0.0.0.dev13/src/gitbolt.egg-info/SOURCES.txt +0 -33
  21. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/LICENSE +0 -0
  22. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/setup.cfg +0 -0
  23. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/_internal_init.py +0 -0
  24. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/add.py +0 -0
  25. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/constants.py +0 -0
  26. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/exceptions.py +0 -0
  27. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/ls_tree.py +0 -0
  28. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/models.py +0 -0
  29. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/py.typed +0 -0
  30. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/pytest_plugin.py +0 -0
  31. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/_internal_init.py +0 -0
  32. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/constants.py +0 -0
  33. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/impl/__init__.py +0 -0
  34. {gitbolt-0.0.0.dev13/src/gitbolt/git_subprocess → gitbolt-0.0.0.dev15/src/gitbolt/subprocess}/utils.py +0 -0
  35. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt/utils.py +0 -0
  36. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt.egg-info/dependency_links.txt +0 -0
  37. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/src/gitbolt.egg-info/entry_points.txt +0 -0
  38. {gitbolt-0.0.0.dev13 → gitbolt-0.0.0.dev15}/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.dev13
3
+ Version: 0.0.0.dev15
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>
@@ -26,7 +26,7 @@ Classifier: Typing :: Typed
26
26
  Requires-Python: >=3.12
27
27
  Description-Content-Type: text/markdown
28
28
  License-File: LICENSE
29
- Requires-Dist: vt-err-hndlr>=0.0.0dev5
29
+ Requires-Dist: vt-err-hndlr>=0.0.0dev6
30
30
  Requires-Dist: vt-commons>=0.0.1.dev9
31
31
  Provides-Extra: pygit2
32
32
  Requires-Dist: pygit2; extra == "pygit2"
@@ -114,9 +114,8 @@ Gitbolt lets you pass subcommands around as typed objects. This enables highly f
114
114
 
115
115
  ```python
116
116
  import gitbolt
117
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
118
117
 
119
- git = SimpleGitCommand()
118
+ git = gitbolt.get_git()
120
119
  version_subcmd = git.version_subcmd
121
120
  add_subcmd = git.add_subcmd
122
121
 
@@ -136,11 +135,11 @@ method_which_only_adds_a_file(add_subcmd)
136
135
  git subcommands are modeled as terminal functions that return stdout.
137
136
 
138
137
  ```python
139
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
138
+ import gitbolt
140
139
 
141
- git = SimpleGitCommand()
142
- status_out = git.status_subcmd.status()
143
- print(status_out)
140
+ git = gitbolt.get_git()
141
+ version_stdout = git.version_subcmd.version().version()
142
+ print(version_stdout)
144
143
  ```
145
144
 
146
145
  ### 🪼 Modular Architecture
@@ -206,9 +205,9 @@ Extensive use of type-hints ensures that invalid usages fail early — at *compi
206
205
  #### 🔁 Override a single Git env (e.g., `GIT_TRACE`)
207
206
 
208
207
  ```python
209
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
208
+ import gitbolt
210
209
 
211
- git = SimpleGitCommand()
210
+ git = gitbolt.get_git()
212
211
  git = git.git_envs_override(GIT_TRACE=True)
213
212
  ```
214
213
 
@@ -216,9 +215,9 @@ git = git.git_envs_override(GIT_TRACE=True)
216
215
 
217
216
  ```python
218
217
  from pathlib import Path
219
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
218
+ import gitbolt
220
219
 
221
- git = SimpleGitCommand()
220
+ git = gitbolt.get_git()
222
221
  git = git.git_envs_override(GIT_TRACE=1, GIT_DIR=Path('/tmp/git-dir/'), GIT_EDITOR='vim')
223
222
  ```
224
223
 
@@ -226,9 +225,9 @@ git = git.git_envs_override(GIT_TRACE=1, GIT_DIR=Path('/tmp/git-dir/'), GIT_EDIT
226
225
 
227
226
  ```python
228
227
  from pathlib import Path
229
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
228
+ import gitbolt
230
229
 
231
- git = SimpleGitCommand()
230
+ git = gitbolt.get_git()
232
231
  overridden_git = git.git_envs_override(GIT_SSH=Path('/tmp/SSH')).git_envs_override(
233
232
  GIT_TERMINAL_PROMPT=1,
234
233
  GIT_NO_REPLACE_OBJECTS=True
@@ -239,10 +238,10 @@ re_overridden_git = overridden_git.git_envs_override(GIT_TRACE=True)
239
238
  #### ❌ Unset Git envs using a special `UNSET` marker
240
239
 
241
240
  ```python
242
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
241
+ import gitbolt
243
242
  from vt.utils.commons.commons.core_py import UNSET
244
243
 
245
- git = SimpleGitCommand()
244
+ git = gitbolt.get_git()
246
245
  overridden_git = git.git_envs_override(GIT_ADVICE=True, GIT_TRACE=True)
247
246
  no_advice_unset_git = overridden_git.git_envs_override(GIT_TRACE=UNSET)
248
247
  ```
@@ -250,9 +249,9 @@ no_advice_unset_git = overridden_git.git_envs_override(GIT_TRACE=UNSET)
250
249
  #### 🔄 Reset Git envs by setting new values
251
250
 
252
251
  ```python
253
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
252
+ import gitbolt
254
253
 
255
- git = SimpleGitCommand()
254
+ git = gitbolt.get_git()
256
255
  overridden_git = git.git_envs_override(GIT_TRACE=True)
257
256
  git_trace_reset_git = overridden_git.git_envs_override(GIT_TRACE=False)
258
257
  ```
@@ -268,9 +267,9 @@ git_trace_reset_git = overridden_git.git_envs_override(GIT_TRACE=False)
268
267
  #### 🔁 Override a single Git opt (e.g., `--no-replace-objects`)
269
268
 
270
269
  ```python
271
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
270
+ import gitbolt
272
271
 
273
- git = SimpleGitCommand()
272
+ git = gitbolt.get_git()
274
273
  git = git.git_opts_override(no_replace_objects=True)
275
274
  ```
276
275
 
@@ -278,7 +277,7 @@ git = git.git_opts_override(no_replace_objects=True)
278
277
 
279
278
  ```python
280
279
  from pathlib import Path
281
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
280
+ from gitbolt.subprocess.impl.simple import SimpleGitCommand
282
281
 
283
282
  git = SimpleGitCommand()
284
283
  git = git.git_opts_override(no_replace_objects=True, git_dir=Path(), paginate=True)
@@ -287,10 +286,10 @@ git = git.git_opts_override(no_replace_objects=True, git_dir=Path(), paginate=Tr
287
286
  #### 🪢 Chain multiple option overrides fluently
288
287
 
289
288
  ```python
289
+ import gitbolt
290
290
  from pathlib import Path
291
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
292
291
 
293
- git = SimpleGitCommand()
292
+ git = gitbolt.get_git()
294
293
  overridden_git = git.git_opts_override(exec_path=Path('tmp')).git_opts_override(
295
294
  noglob_pathspecs=True,
296
295
  no_advice=True
@@ -303,11 +302,11 @@ re_overridden_git = overridden_git.git_opts_override(glob_pathspecs=True)
303
302
  #### ❌ Unset Git opts using a special `UNSET` marker
304
303
 
305
304
  ```python
305
+ import gitbolt
306
306
  from pathlib import Path
307
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
308
307
  from vt.utils.commons.commons.core_py import UNSET
309
308
 
310
- git = SimpleGitCommand()
309
+ git = gitbolt.get_git()
311
310
  overridden_git = git.git_opts_override(exec_path=Path('tmp'), no_advice=True)
312
311
  no_advice_unset_git = overridden_git.git_opts_override(no_advice=UNSET)
313
312
  ```
@@ -315,9 +314,9 @@ no_advice_unset_git = overridden_git.git_opts_override(no_advice=UNSET)
315
314
  #### 🔄 Reset Git opts by setting new values
316
315
 
317
316
  ```python
318
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
317
+ import gitbolt
319
318
 
320
- git = SimpleGitCommand()
319
+ git = gitbolt.get_git()
321
320
  overridden_git = git.git_opts_override(no_advice=True)
322
321
  no_advice_reset_git = overridden_git.git_opts_override(no_advice=False)
323
322
  ```
@@ -333,9 +332,9 @@ Introduced in `0.0.0dev4` to
333
332
  - have consistent interfaced commands run until all subcommands are provided by the library.
334
333
 
335
334
  ```python
336
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
335
+ import gitbolt
337
336
 
338
- git = SimpleGitCommand()
337
+ git = gitbolt.get_git_command()
339
338
  git = git.git_opts_override(no_advice=True)
340
339
  git.subcmd_unchecked.run(['--version']) # run the version option for git.
341
340
  git.subcmd_unchecked.run(['version']) # run the version subcommand.
@@ -350,11 +349,11 @@ would be to make a system that receives CLI commands and does certain modificati
350
349
  actually running them. An example:
351
350
 
352
351
  ```python
353
- from gitbolt.git_subprocess.impl.simple import CLISimpleGitCommand
352
+ import gitbolt
354
353
 
355
- opts = ["--no-pager", "--namespace", "n1"] # options received from outside your program.
356
- envs = dict(GIT_AUTHOR_NAME="ss") # env-vars received form outside your program.
357
- git = CLISimpleGitCommand(opts=opts, envs=envs)
354
+ opts = ["--no-pager", "--namespace", "n1"] # options received from outside your program.
355
+ envs = dict(GIT_AUTHOR_NAME="ss") # env-vars received form outside your program.
356
+ git = gitbolt.get_git_command(opts=opts, envs=envs)
358
357
 
359
358
  # these can later be overridden
360
359
  git = git.git_opts_override(namespace="n2")
@@ -78,9 +78,8 @@ Gitbolt lets you pass subcommands around as typed objects. This enables highly f
78
78
 
79
79
  ```python
80
80
  import gitbolt
81
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
82
81
 
83
- git = SimpleGitCommand()
82
+ git = gitbolt.get_git()
84
83
  version_subcmd = git.version_subcmd
85
84
  add_subcmd = git.add_subcmd
86
85
 
@@ -100,11 +99,11 @@ method_which_only_adds_a_file(add_subcmd)
100
99
  git subcommands are modeled as terminal functions that return stdout.
101
100
 
102
101
  ```python
103
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
102
+ import gitbolt
104
103
 
105
- git = SimpleGitCommand()
106
- status_out = git.status_subcmd.status()
107
- print(status_out)
104
+ git = gitbolt.get_git()
105
+ version_stdout = git.version_subcmd.version().version()
106
+ print(version_stdout)
108
107
  ```
109
108
 
110
109
  ### 🪼 Modular Architecture
@@ -170,9 +169,9 @@ Extensive use of type-hints ensures that invalid usages fail early — at *compi
170
169
  #### 🔁 Override a single Git env (e.g., `GIT_TRACE`)
171
170
 
172
171
  ```python
173
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
172
+ import gitbolt
174
173
 
175
- git = SimpleGitCommand()
174
+ git = gitbolt.get_git()
176
175
  git = git.git_envs_override(GIT_TRACE=True)
177
176
  ```
178
177
 
@@ -180,9 +179,9 @@ git = git.git_envs_override(GIT_TRACE=True)
180
179
 
181
180
  ```python
182
181
  from pathlib import Path
183
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
182
+ import gitbolt
184
183
 
185
- git = SimpleGitCommand()
184
+ git = gitbolt.get_git()
186
185
  git = git.git_envs_override(GIT_TRACE=1, GIT_DIR=Path('/tmp/git-dir/'), GIT_EDITOR='vim')
187
186
  ```
188
187
 
@@ -190,9 +189,9 @@ git = git.git_envs_override(GIT_TRACE=1, GIT_DIR=Path('/tmp/git-dir/'), GIT_EDIT
190
189
 
191
190
  ```python
192
191
  from pathlib import Path
193
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
192
+ import gitbolt
194
193
 
195
- git = SimpleGitCommand()
194
+ git = gitbolt.get_git()
196
195
  overridden_git = git.git_envs_override(GIT_SSH=Path('/tmp/SSH')).git_envs_override(
197
196
  GIT_TERMINAL_PROMPT=1,
198
197
  GIT_NO_REPLACE_OBJECTS=True
@@ -203,10 +202,10 @@ re_overridden_git = overridden_git.git_envs_override(GIT_TRACE=True)
203
202
  #### ❌ Unset Git envs using a special `UNSET` marker
204
203
 
205
204
  ```python
206
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
205
+ import gitbolt
207
206
  from vt.utils.commons.commons.core_py import UNSET
208
207
 
209
- git = SimpleGitCommand()
208
+ git = gitbolt.get_git()
210
209
  overridden_git = git.git_envs_override(GIT_ADVICE=True, GIT_TRACE=True)
211
210
  no_advice_unset_git = overridden_git.git_envs_override(GIT_TRACE=UNSET)
212
211
  ```
@@ -214,9 +213,9 @@ no_advice_unset_git = overridden_git.git_envs_override(GIT_TRACE=UNSET)
214
213
  #### 🔄 Reset Git envs by setting new values
215
214
 
216
215
  ```python
217
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
216
+ import gitbolt
218
217
 
219
- git = SimpleGitCommand()
218
+ git = gitbolt.get_git()
220
219
  overridden_git = git.git_envs_override(GIT_TRACE=True)
221
220
  git_trace_reset_git = overridden_git.git_envs_override(GIT_TRACE=False)
222
221
  ```
@@ -232,9 +231,9 @@ git_trace_reset_git = overridden_git.git_envs_override(GIT_TRACE=False)
232
231
  #### 🔁 Override a single Git opt (e.g., `--no-replace-objects`)
233
232
 
234
233
  ```python
235
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
234
+ import gitbolt
236
235
 
237
- git = SimpleGitCommand()
236
+ git = gitbolt.get_git()
238
237
  git = git.git_opts_override(no_replace_objects=True)
239
238
  ```
240
239
 
@@ -242,7 +241,7 @@ git = git.git_opts_override(no_replace_objects=True)
242
241
 
243
242
  ```python
244
243
  from pathlib import Path
245
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
244
+ from gitbolt.subprocess.impl.simple import SimpleGitCommand
246
245
 
247
246
  git = SimpleGitCommand()
248
247
  git = git.git_opts_override(no_replace_objects=True, git_dir=Path(), paginate=True)
@@ -251,10 +250,10 @@ git = git.git_opts_override(no_replace_objects=True, git_dir=Path(), paginate=Tr
251
250
  #### 🪢 Chain multiple option overrides fluently
252
251
 
253
252
  ```python
253
+ import gitbolt
254
254
  from pathlib import Path
255
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
256
255
 
257
- git = SimpleGitCommand()
256
+ git = gitbolt.get_git()
258
257
  overridden_git = git.git_opts_override(exec_path=Path('tmp')).git_opts_override(
259
258
  noglob_pathspecs=True,
260
259
  no_advice=True
@@ -267,11 +266,11 @@ re_overridden_git = overridden_git.git_opts_override(glob_pathspecs=True)
267
266
  #### ❌ Unset Git opts using a special `UNSET` marker
268
267
 
269
268
  ```python
269
+ import gitbolt
270
270
  from pathlib import Path
271
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
272
271
  from vt.utils.commons.commons.core_py import UNSET
273
272
 
274
- git = SimpleGitCommand()
273
+ git = gitbolt.get_git()
275
274
  overridden_git = git.git_opts_override(exec_path=Path('tmp'), no_advice=True)
276
275
  no_advice_unset_git = overridden_git.git_opts_override(no_advice=UNSET)
277
276
  ```
@@ -279,9 +278,9 @@ no_advice_unset_git = overridden_git.git_opts_override(no_advice=UNSET)
279
278
  #### 🔄 Reset Git opts by setting new values
280
279
 
281
280
  ```python
282
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
281
+ import gitbolt
283
282
 
284
- git = SimpleGitCommand()
283
+ git = gitbolt.get_git()
285
284
  overridden_git = git.git_opts_override(no_advice=True)
286
285
  no_advice_reset_git = overridden_git.git_opts_override(no_advice=False)
287
286
  ```
@@ -297,9 +296,9 @@ Introduced in `0.0.0dev4` to
297
296
  - have consistent interfaced commands run until all subcommands are provided by the library.
298
297
 
299
298
  ```python
300
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
299
+ import gitbolt
301
300
 
302
- git = SimpleGitCommand()
301
+ git = gitbolt.get_git_command()
303
302
  git = git.git_opts_override(no_advice=True)
304
303
  git.subcmd_unchecked.run(['--version']) # run the version option for git.
305
304
  git.subcmd_unchecked.run(['version']) # run the version subcommand.
@@ -314,11 +313,11 @@ would be to make a system that receives CLI commands and does certain modificati
314
313
  actually running them. An example:
315
314
 
316
315
  ```python
317
- from gitbolt.git_subprocess.impl.simple import CLISimpleGitCommand
316
+ import gitbolt
318
317
 
319
- opts = ["--no-pager", "--namespace", "n1"] # options received from outside your program.
320
- envs = dict(GIT_AUTHOR_NAME="ss") # env-vars received form outside your program.
321
- git = CLISimpleGitCommand(opts=opts, envs=envs)
318
+ opts = ["--no-pager", "--namespace", "n1"] # options received from outside your program.
319
+ envs = dict(GIT_AUTHOR_NAME="ss") # env-vars received form outside your program.
320
+ git = gitbolt.get_git_command(opts=opts, envs=envs)
322
321
 
323
322
  # these can later be overridden
324
323
  git = git.git_opts_override(namespace="n2")
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gitbolt"
3
- version = "0.0.0dev13"
3
+ version = "0.0.0dev15"
4
4
  description = "Fast, flexible and type-safe Git commands in Python."
5
5
  requires-python = ">=3.12"
6
6
  readme = "README.md"
@@ -36,7 +36,7 @@ classifiers = [
36
36
  "Typing :: Typed"
37
37
  ]
38
38
  dependencies = [
39
- "vt-err-hndlr >= 0.0.0dev5",
39
+ "vt-err-hndlr >= 0.0.0dev6",
40
40
  "vt-commons >= 0.0.1.dev9",
41
41
  ]
42
42
 
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env python3
2
+ # coding=utf-8
3
+
4
+ """
5
+ Git command interfaces with default implementation using subprocess calls.
6
+ """
7
+
8
+ from pathlib import Path
9
+
10
+ # region imports
11
+ # region base related imports
12
+ from gitbolt.base import Git as Git
13
+ from gitbolt.base import CanOverrideGitOpts as CanOverrideGitOpts
14
+ from gitbolt.base import HasGitUnderneath as HasGitUnderneath
15
+ from gitbolt.base import GitSubCommand as GitSubCommand
16
+ from gitbolt.base import LsTree as LsTree
17
+ from gitbolt.base import Version as Version
18
+ from gitbolt.base import Add as Add
19
+ from gitbolt.subprocess.base import GitCommand
20
+ # endregion
21
+
22
+
23
+ from gitbolt.constants import GIT_DIR as GIT_DIR
24
+ from gitbolt.subprocess.constants import GIT_CMD
25
+ from gitbolt.subprocess.impl.simple import SimpleGitCommand as _SimpleGitCommand
26
+ from gitbolt.subprocess.impl.simple import CLISimpleGitCommand as _CLISimpleGitCommand
27
+ from gitbolt.subprocess.runner.simple import SimpleGitCR as _SimpleGitCR
28
+ # endregion
29
+
30
+
31
+ def get_git(git_root_dir: Path = Path.cwd()) -> Git:
32
+ """
33
+ Get operational and programmatic ``Git``.
34
+
35
+ Examples:
36
+
37
+ * Get git version:
38
+
39
+ >>> import subprocess
40
+ >>> import gitbolt
41
+ >>> git = gitbolt.get_git()
42
+ >>> assert git.version().version() == subprocess.run(['git', 'version'], capture_output=True, text=True).stdout.strip()
43
+
44
+ :param git_root_dir: Path to the git repo root directory. Defaults to current working directory.
45
+ :returns: The ``Git`` instance with all subcommands.
46
+ """
47
+
48
+ return _SimpleGitCommand(git_root_dir)
49
+
50
+
51
+ def get_git_command(
52
+ git_root_dir: Path = Path.cwd(),
53
+ *,
54
+ git_prog: str | Path = GIT_CMD,
55
+ opts: list[str] | None = None,
56
+ envs: dict[str, str] | None = None,
57
+ prefer_cli: bool = False,
58
+ ) -> GitCommand:
59
+ """
60
+ Get operational and programmatic ``Git`` which runs as a subprocess.
61
+
62
+ Examples:
63
+
64
+ * Get git version, as base git:
65
+
66
+ >>> import subprocess
67
+ >>> import gitbolt
68
+ >>> git = gitbolt.get_git_command()
69
+ >>> assert git.version().version() == subprocess.run(['git', 'version'], capture_output=True, text=True).stdout.strip()
70
+
71
+ * Get git version, as a git subcommand. Runs git in subprocess:
72
+
73
+ >>> assert git.subcmd_unchecked.run(["version"], text=True).stdout.strip() == subprocess.run(['git', 'version'], capture_output=True, text=True).stdout.strip()
74
+
75
+ :param git_root_dir: Path to the git repo root directory. Defaults to current working directory.
76
+ :param git_prog: git program name/location. Useful when user wants to run a separate git version/git emulator.
77
+ :param opts: main git cli options. The main git command options like ``--no-replace-objects``, ``--no-pager``, ``-C`` etc are git main command args.
78
+ :param envs: main git cli environment variables (env vars). Not supplying any env vars (default behavior: ``None``)
79
+ simply supplies all the env vars to the underlying runner.
80
+ :param prefer_cli: cli opts and envs will be given priority over programmatically set opts and envs. Setting
81
+ this param to ``True`` will make cli opts and envs appear later in the opts and envs strings which will
82
+ make them override previously programmatically set opts and envs.
83
+ :returns: ``GitCommand`` instance with all the subcommands as well as ``unchecked_subcmd``. Runs git commands in a
84
+ separate runner in subprocess.
85
+ """
86
+ runner = _SimpleGitCR(git_prog)
87
+ if opts is None:
88
+ return _SimpleGitCommand(git_root_dir, runner)
89
+ else:
90
+ return _CLISimpleGitCommand(
91
+ git_root_dir,
92
+ runner,
93
+ opts=opts,
94
+ envs=envs,
95
+ prefer_cli=prefer_cli,
96
+ )
@@ -20,29 +20,21 @@ from gitbolt.ls_tree import LsTreeArgsValidator, UtilLsTreeArgsValidator
20
20
  from gitbolt.add import AddArgsValidator, UtilAddArgsValidator
21
21
 
22
22
 
23
- class ForGit(Protocol):
24
- """
25
- Marker interface to mark an operation for git.
26
- """
27
-
28
- pass
29
-
30
-
31
- class HasGitUnderneath[G: "Git"](ForGit, Protocol):
23
+ class HasGitUnderneath[G: "Git"](Protocol):
32
24
  """
33
25
  Stores a reference to main git instance.
34
26
  """
35
27
 
36
28
  @property
37
29
  @abstractmethod
38
- def underlying_git(self) -> G:
30
+ def git(self) -> G:
39
31
  """
40
- :return: stored git instance reference.
32
+ :return: stored underlying git instance reference.
41
33
  """
42
34
  ...
43
35
 
44
36
 
45
- class CanOverrideGitOpts(ForGit, Protocol):
37
+ class CanOverrideGitOpts(Protocol):
46
38
  """
47
39
  Can override main git command options.
48
40
 
@@ -65,7 +57,7 @@ class CanOverrideGitOpts(ForGit, Protocol):
65
57
  ...
66
58
 
67
59
 
68
- class CanOverrideGitEnvs(ForGit, Protocol):
60
+ class CanOverrideGitEnvs(Protocol):
69
61
  """
70
62
  Can override main git command environment variables.
71
63
 
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env python3
2
+ # coding=utf-8
3
+
4
+ """
5
+ Git command interfaces with implementation using subprocess calls.
6
+ """
7
+
8
+ # region gitbolt.subprocess.base
9
+ from gitbolt.subprocess.base import GitCommand as GitCommand
10
+ from gitbolt.subprocess.base import GitSubcmdCommand as GitSubcmdCommand
11
+ from gitbolt.subprocess.base import AddCommand as AddCommand
12
+ from gitbolt.subprocess.base import LsTreeCommand as LsTreeCommand
13
+ from gitbolt.subprocess.base import VersionCommand as VersionCommand
14
+ from gitbolt.subprocess.base import UncheckedSubcmd as UncheckedSubcmd
15
+ # endregion
@@ -9,7 +9,7 @@ from abc import abstractmethod
9
9
  from pathlib import Path
10
10
  from typing import Protocol, Unpack, override, Literal
11
11
 
12
- from gitbolt.git_subprocess.constants import ADD_CMD
12
+ from gitbolt.subprocess.constants import ADD_CMD
13
13
  from gitbolt.models import GitAddOpts
14
14
 
15
15
 
@@ -19,12 +19,12 @@ from vt.utils.errors.error_specs import ERR_INVALID_USAGE
19
19
 
20
20
  from gitbolt import Git, Version, LsTree, GitSubCommand, HasGitUnderneath, Add
21
21
  from gitbolt.exceptions import GitExitingException
22
- from gitbolt.git_subprocess.add import AddCLIArgsBuilder, IndividuallyOverridableACAB
23
- from gitbolt.git_subprocess.ls_tree import (
22
+ from gitbolt.subprocess.add import AddCLIArgsBuilder, IndividuallyOverridableACAB
23
+ from gitbolt.subprocess.ls_tree import (
24
24
  LsTreeCLIArgsBuilder,
25
25
  IndividuallyOverridableLTCAB,
26
26
  )
27
- from gitbolt.git_subprocess.runner import GitCommandRunner
27
+ from gitbolt.subprocess.runner import GitCommandRunner
28
28
  from gitbolt.models import GitOpts, GitLsTreeOpts, GitAddOpts, GitEnvVars
29
29
  from gitbolt.utils import merge_git_opts, merge_git_envs
30
30
 
@@ -306,13 +306,13 @@ class GitSubcmdCommand(GitSubCommand, HasGitUnderneath["GitCommand"], Protocol):
306
306
 
307
307
  @override
308
308
  def git_opts_override(self, **overrides: Unpack[GitOpts]) -> Self:
309
- overridden_git = self.underlying_git.git_opts_override(**overrides)
309
+ overridden_git = self.git.git_opts_override(**overrides)
310
310
  self._set_underlying_git(overridden_git)
311
311
  return self
312
312
 
313
313
  @override
314
314
  def git_envs_override(self, **overrides: Unpack[GitEnvVars]) -> Self:
315
- overridden_git = self.underlying_git.git_envs_override(**overrides)
315
+ overridden_git = self.git.git_envs_override(**overrides)
316
316
  self._set_underlying_git(overridden_git)
317
317
  return self
318
318
 
@@ -403,11 +403,11 @@ class LsTreeCommand(LsTree, GitSubcmdCommand, Protocol):
403
403
  def ls_tree(self, tree_ish: str, **ls_tree_opts: Unpack[GitLsTreeOpts]) -> str:
404
404
  self.args_validator.validate(tree_ish, **ls_tree_opts)
405
405
  sub_cmd_args = self.cli_args_builder.build(tree_ish, **ls_tree_opts)
406
- main_cmd_args = self.underlying_git.build_main_cmd_args()
407
- env_vars = self.underlying_git.build_git_envs()
406
+ main_cmd_args = self.git.build_main_cmd_args()
407
+ env_vars = self.git.build_git_envs()
408
408
 
409
409
  # Run the git command
410
- result = self.underlying_git.runner.run_git_command(
410
+ result = self.git.runner.run_git_command(
411
411
  main_cmd_args,
412
412
  sub_cmd_args,
413
413
  check=True,
@@ -485,11 +485,11 @@ class AddCommand(Add, GitSubcmdCommand, Protocol):
485
485
  pathspec_file_nul=pathspec_file_nul,
486
486
  **add_opts,
487
487
  )
488
- main_cmd_args = self.underlying_git.build_main_cmd_args()
489
- env_vars = self.underlying_git.build_git_envs()
488
+ main_cmd_args = self.git.build_main_cmd_args()
489
+ env_vars = self.git.build_git_envs()
490
490
 
491
491
  # Run the git command
492
- result = self.underlying_git.runner.run_git_command(
492
+ result = self.git.runner.run_git_command(
493
493
  main_cmd_args,
494
494
  sub_cmd_args,
495
495
  _input=pathspec_stdin,
@@ -584,8 +584,8 @@ class UncheckedSubcmd(GitSubcmdCommand, RootDirOp, Protocol):
584
584
 
585
585
  :return: ``CompletedProcess`` capturing all the required stdout, stderr, return-code etc.
586
586
  """
587
- main_cmd_args = self.underlying_git.build_main_cmd_args()
588
- envs_vars = self.underlying_git.build_git_envs()
587
+ main_cmd_args = self.git.build_main_cmd_args()
588
+ envs_vars = self.git.build_git_envs()
589
589
  another_supplied_env = subprocess_run_kwargs.pop("env", None)
590
590
  if another_supplied_env:
591
591
  if envs_vars is not None:
@@ -594,7 +594,7 @@ class UncheckedSubcmd(GitSubcmdCommand, RootDirOp, Protocol):
594
594
  capture_output = subprocess_run_kwargs.pop("capture_output", True)
595
595
  check = subprocess_run_kwargs.pop("check", True)
596
596
  # Run the git command
597
- result = self.underlying_git.runner.run_git_command(
597
+ result = self.git.runner.run_git_command(
598
598
  main_cmd_args,
599
599
  subcommand_args,
600
600
  *subprocess_run_args,
@@ -22,26 +22,26 @@ class GitCmdException(GitException, VTCmdException):
22
22
 
23
23
  >>> raise GitCmdException(called_process_error=CalledProcessError(1, ['git', 'status'])) # always use `from` clause.
24
24
  Traceback (most recent call last):
25
- gitbolt.git_subprocess.exceptions.GitCmdException: CalledProcessError: Command '['git', 'status']' returned non-zero exit status 1.
25
+ gitbolt.subprocess.exceptions.GitCmdException: CalledProcessError: Command '['git', 'status']' returned non-zero exit status 1.
26
26
 
27
27
  * raise with a message:
28
28
 
29
29
  >>> raise GitCmdException('Git failed', called_process_error=CalledProcessError(1, ['git', 'push'])) # always use `from` clause.
30
30
  Traceback (most recent call last):
31
- gitbolt.git_subprocess.exceptions.GitCmdException: CalledProcessError: Git failed
31
+ gitbolt.subprocess.exceptions.GitCmdException: CalledProcessError: Git failed
32
32
 
33
33
  * raise with overridden exit code:
34
34
 
35
35
  >>> raise GitCmdException('Git push failed', called_process_error=CalledProcessError(1, ['git', 'push']), exit_code=42) # always use `from` clause.
36
36
  Traceback (most recent call last):
37
- gitbolt.git_subprocess.exceptions.GitCmdException: CalledProcessError: Git push failed
37
+ gitbolt.subprocess.exceptions.GitCmdException: CalledProcessError: Git push failed
38
38
 
39
39
  * raise without message, override with stderr inside CalledProcessError:
40
40
 
41
41
  >>> err = CalledProcessError(128, ['git', 'fetch'], stderr='fatal: not a git repository')
42
42
  >>> raise GitCmdException(called_process_error=err) # always use `from` clause.
43
43
  Traceback (most recent call last):
44
- gitbolt.git_subprocess.exceptions.GitCmdException: CalledProcessError: Command '['git', 'fetch']' returned non-zero exit status 128.
44
+ gitbolt.subprocess.exceptions.GitCmdException: CalledProcessError: Command '['git', 'fetch']' returned non-zero exit status 128.
45
45
 
46
46
  * raise exception using `from` clause (chaining):
47
47
 
@@ -50,7 +50,7 @@ class GitCmdException(GitException, VTCmdException):
50
50
  ... except CalledProcessError as e:
51
51
  ... raise GitCmdException('Clone failed', called_process_error=e) from e
52
52
  Traceback (most recent call last):
53
- gitbolt.git_subprocess.exceptions.GitCmdException: CalledProcessError: Clone failed
53
+ gitbolt.subprocess.exceptions.GitCmdException: CalledProcessError: Clone failed
54
54
 
55
55
  * cause reflects original CalledProcessError when chained:
56
56
 
@@ -15,7 +15,7 @@ from vt.utils.commons.commons.op import RootDirOp
15
15
 
16
16
  from gitbolt.base import Version
17
17
  from gitbolt.add import AddArgsValidator
18
- from gitbolt.git_subprocess import (
18
+ from gitbolt.subprocess import (
19
19
  GitCommand,
20
20
  VersionCommand,
21
21
  LsTreeCommand,
@@ -23,11 +23,11 @@ from gitbolt.git_subprocess import (
23
23
  AddCommand,
24
24
  UncheckedSubcmd,
25
25
  )
26
- from gitbolt.git_subprocess.add import AddCLIArgsBuilder
27
- from gitbolt.git_subprocess.constants import VERSION_CMD
28
- from gitbolt.git_subprocess.ls_tree import LsTreeCLIArgsBuilder
29
- from gitbolt.git_subprocess.runner import GitCommandRunner
30
- from gitbolt.git_subprocess.runner.simple_impl import SimpleGitCR
26
+ from gitbolt.subprocess.add import AddCLIArgsBuilder
27
+ from gitbolt.subprocess.constants import VERSION_CMD
28
+ from gitbolt.subprocess.ls_tree import LsTreeCLIArgsBuilder
29
+ from gitbolt.subprocess.runner import GitCommandRunner
30
+ from gitbolt.subprocess.runner.simple import SimpleGitCR
31
31
  from gitbolt.ls_tree import LsTreeArgsValidator
32
32
 
33
33
 
@@ -36,7 +36,7 @@ class GitSubcmdCommandImpl(GitSubcmdCommand, ABC):
36
36
  self._underlying_git = git
37
37
 
38
38
  @property
39
- def underlying_git(self) -> GitCommand:
39
+ def git(self) -> GitCommand:
40
40
  return self._underlying_git
41
41
 
42
42
  def _set_underlying_git(self, git: "GitCommand") -> None:
@@ -55,14 +55,14 @@ class VersionCommandImpl(VersionCommand, GitSubcmdCommandImpl):
55
55
  self, build_options: Literal[True, False] = False
56
56
  ) -> Version.VersionInfo | Version.VersionWithBuildInfo:
57
57
  self._require_valid_args(build_options)
58
- main_cmd_args = self.underlying_git.build_main_cmd_args()
58
+ main_cmd_args = self.git.build_main_cmd_args()
59
59
  sub_cmd_args = [VERSION_CMD]
60
- env_vars = self.underlying_git.build_git_envs()
60
+ env_vars = self.git.build_git_envs()
61
61
  if build_options:
62
62
  sub_cmd_args.append("--build-options")
63
63
 
64
64
  def rosetta_supplier():
65
- return self.underlying_git.runner.run_git_command(
65
+ return self.git.runner.run_git_command(
66
66
  main_cmd_args,
67
67
  sub_cmd_args,
68
68
  check=True,
@@ -76,7 +76,7 @@ class VersionCommandImpl(VersionCommand, GitSubcmdCommandImpl):
76
76
  return VersionCommand.VersionInfoForCmd(rosetta_supplier)
77
77
 
78
78
  def clone(self) -> "VersionCommandImpl":
79
- return VersionCommandImpl(self.underlying_git)
79
+ return VersionCommandImpl(self.git)
80
80
 
81
81
 
82
82
  class LsTreeCommandImpl(LsTreeCommand, GitSubcmdCommandImpl):
@@ -117,7 +117,7 @@ class LsTreeCommandImpl(LsTreeCommand, GitSubcmdCommandImpl):
117
117
  return self._cli_args_builder
118
118
 
119
119
  def clone(self) -> "LsTreeCommandImpl":
120
- return LsTreeCommandImpl(self.root_dir, self.underlying_git)
120
+ return LsTreeCommandImpl(self.root_dir, self.git)
121
121
 
122
122
 
123
123
  class AddCommandImpl(AddCommand, GitSubcmdCommandImpl):
@@ -150,7 +150,7 @@ class AddCommandImpl(AddCommand, GitSubcmdCommandImpl):
150
150
  return self._cli_args_builder
151
151
 
152
152
  def clone(self) -> "AddCommandImpl":
153
- return AddCommandImpl(self.root_dir, self.underlying_git)
153
+ return AddCommandImpl(self.root_dir, self.git)
154
154
 
155
155
 
156
156
  class UncheckedSubcmdImpl(UncheckedSubcmd, GitSubcmdCommandImpl):
@@ -164,7 +164,7 @@ class UncheckedSubcmdImpl(UncheckedSubcmd, GitSubcmdCommandImpl):
164
164
  return self._root_dir
165
165
 
166
166
  def clone(self) -> "UncheckedSubcmdImpl":
167
- return UncheckedSubcmdImpl(self.root_dir, self.underlying_git)
167
+ return UncheckedSubcmdImpl(self.root_dir, self.git)
168
168
 
169
169
 
170
170
  class SimpleGitCommand(GitCommand, RootDirOp):
@@ -266,8 +266,8 @@ class CLISimpleGitCommand(SimpleGitCommand):
266
266
  ):
267
267
  """
268
268
  :param opts: main git cli options.
269
- :param envs: main git cli env vars. Not supplying any env vars (default behavior: ``None``) simply supplies all
270
- the env vars to the underlying runner.
269
+ :param envs: main git cli environment variables (env vars). Not supplying any env
270
+ vars (default behavior: ``None``) simply supplies all the env vars to the underlying runner.
271
271
  :param prefer_cli: cli opts and envs will be given priority over programmatically set opts and envs. Setting
272
272
  this param to ``True`` will make cli opts and envs appear later in the opts and envs strings which will
273
273
  make them override previously programmatically set opts and envs.
@@ -8,7 +8,7 @@ Helper interfaces for ``git ls-tree`` subcommand with default implementation for
8
8
  from abc import abstractmethod
9
9
  from typing import Protocol, Unpack, override
10
10
 
11
- from gitbolt.git_subprocess.constants import LS_TREE_CMD
11
+ from gitbolt.subprocess.constants import LS_TREE_CMD
12
12
  from gitbolt.models import GitLsTreeOpts
13
13
 
14
14
 
@@ -5,4 +5,4 @@
5
5
  Git command runners to run subprocess calls.
6
6
  """
7
7
 
8
- from gitbolt.git_subprocess.runner.base import GitCommandRunner as GitCommandRunner
8
+ from gitbolt.subprocess.runner.base import GitCommandRunner as GitCommandRunner
@@ -7,6 +7,7 @@ Git command runner interfaces to run subprocess calls.
7
7
 
8
8
  from __future__ import annotations
9
9
 
10
+ import pathlib
10
11
  from abc import abstractmethod
11
12
  from subprocess import CompletedProcess
12
13
  from typing import Protocol, overload, Any, Literal
@@ -62,3 +63,11 @@ class GitCommandRunner(Protocol):
62
63
  text: Literal[False] = ...,
63
64
  **subprocess_run_kwargs: Any,
64
65
  ) -> CompletedProcess[bytes]: ...
66
+
67
+ @property
68
+ @abstractmethod
69
+ def git_prog(self) -> str | pathlib.Path:
70
+ """
71
+ :returns: git path location or git program name.
72
+ """
73
+ ...
@@ -7,13 +7,14 @@ A simple and straight-forward git command subprocess runner implementation.
7
7
 
8
8
  from __future__ import annotations
9
9
 
10
+ import pathlib
10
11
  import subprocess
11
12
  from subprocess import CompletedProcess
12
13
  from typing import overload, override, Any, Literal
13
14
 
14
- from gitbolt.git_subprocess.constants import GIT_CMD
15
- from gitbolt.git_subprocess.exceptions import GitCmdException
16
- from gitbolt.git_subprocess.runner import GitCommandRunner
15
+ from gitbolt.subprocess.constants import GIT_CMD
16
+ from gitbolt.subprocess.exceptions import GitCmdException
17
+ from gitbolt.subprocess.runner import GitCommandRunner
17
18
 
18
19
 
19
20
  class SimpleGitCR(GitCommandRunner):
@@ -21,6 +22,12 @@ class SimpleGitCR(GitCommandRunner):
21
22
  Simple git command runner that simply runs everything `as-is` in a subprocess.
22
23
  """
23
24
 
25
+ def __init__(self, git_prog: str | pathlib.Path = GIT_CMD):
26
+ """
27
+ :param git_prog: git program name/location. Useful when user wants to run a separate git version/git emulator.
28
+ """
29
+ self._git_prog = git_prog
30
+
24
31
  @overload
25
32
  @override
26
33
  def run_git_command(
@@ -79,7 +86,7 @@ class SimpleGitCR(GitCommandRunner):
79
86
  ) -> CompletedProcess[str] | CompletedProcess[bytes]:
80
87
  try:
81
88
  return subprocess.run(
82
- [GIT_CMD, *main_cmd_args, *subcommand_args],
89
+ [str(self.git_prog), *main_cmd_args, *subcommand_args],
83
90
  *subprocess_run_args,
84
91
  input=_input,
85
92
  text=text,
@@ -89,3 +96,8 @@ class SimpleGitCR(GitCommandRunner):
89
96
  raise GitCmdException(
90
97
  e.stderr, called_process_error=e, exit_code=e.returncode
91
98
  ) from e
99
+
100
+ @override
101
+ @property
102
+ def git_prog(self) -> str | pathlib.Path:
103
+ return self._git_prog
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitbolt
3
- Version: 0.0.0.dev13
3
+ Version: 0.0.0.dev15
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>
@@ -26,7 +26,7 @@ Classifier: Typing :: Typed
26
26
  Requires-Python: >=3.12
27
27
  Description-Content-Type: text/markdown
28
28
  License-File: LICENSE
29
- Requires-Dist: vt-err-hndlr>=0.0.0dev5
29
+ Requires-Dist: vt-err-hndlr>=0.0.0dev6
30
30
  Requires-Dist: vt-commons>=0.0.1.dev9
31
31
  Provides-Extra: pygit2
32
32
  Requires-Dist: pygit2; extra == "pygit2"
@@ -114,9 +114,8 @@ Gitbolt lets you pass subcommands around as typed objects. This enables highly f
114
114
 
115
115
  ```python
116
116
  import gitbolt
117
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
118
117
 
119
- git = SimpleGitCommand()
118
+ git = gitbolt.get_git()
120
119
  version_subcmd = git.version_subcmd
121
120
  add_subcmd = git.add_subcmd
122
121
 
@@ -136,11 +135,11 @@ method_which_only_adds_a_file(add_subcmd)
136
135
  git subcommands are modeled as terminal functions that return stdout.
137
136
 
138
137
  ```python
139
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
138
+ import gitbolt
140
139
 
141
- git = SimpleGitCommand()
142
- status_out = git.status_subcmd.status()
143
- print(status_out)
140
+ git = gitbolt.get_git()
141
+ version_stdout = git.version_subcmd.version().version()
142
+ print(version_stdout)
144
143
  ```
145
144
 
146
145
  ### 🪼 Modular Architecture
@@ -206,9 +205,9 @@ Extensive use of type-hints ensures that invalid usages fail early — at *compi
206
205
  #### 🔁 Override a single Git env (e.g., `GIT_TRACE`)
207
206
 
208
207
  ```python
209
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
208
+ import gitbolt
210
209
 
211
- git = SimpleGitCommand()
210
+ git = gitbolt.get_git()
212
211
  git = git.git_envs_override(GIT_TRACE=True)
213
212
  ```
214
213
 
@@ -216,9 +215,9 @@ git = git.git_envs_override(GIT_TRACE=True)
216
215
 
217
216
  ```python
218
217
  from pathlib import Path
219
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
218
+ import gitbolt
220
219
 
221
- git = SimpleGitCommand()
220
+ git = gitbolt.get_git()
222
221
  git = git.git_envs_override(GIT_TRACE=1, GIT_DIR=Path('/tmp/git-dir/'), GIT_EDITOR='vim')
223
222
  ```
224
223
 
@@ -226,9 +225,9 @@ git = git.git_envs_override(GIT_TRACE=1, GIT_DIR=Path('/tmp/git-dir/'), GIT_EDIT
226
225
 
227
226
  ```python
228
227
  from pathlib import Path
229
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
228
+ import gitbolt
230
229
 
231
- git = SimpleGitCommand()
230
+ git = gitbolt.get_git()
232
231
  overridden_git = git.git_envs_override(GIT_SSH=Path('/tmp/SSH')).git_envs_override(
233
232
  GIT_TERMINAL_PROMPT=1,
234
233
  GIT_NO_REPLACE_OBJECTS=True
@@ -239,10 +238,10 @@ re_overridden_git = overridden_git.git_envs_override(GIT_TRACE=True)
239
238
  #### ❌ Unset Git envs using a special `UNSET` marker
240
239
 
241
240
  ```python
242
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
241
+ import gitbolt
243
242
  from vt.utils.commons.commons.core_py import UNSET
244
243
 
245
- git = SimpleGitCommand()
244
+ git = gitbolt.get_git()
246
245
  overridden_git = git.git_envs_override(GIT_ADVICE=True, GIT_TRACE=True)
247
246
  no_advice_unset_git = overridden_git.git_envs_override(GIT_TRACE=UNSET)
248
247
  ```
@@ -250,9 +249,9 @@ no_advice_unset_git = overridden_git.git_envs_override(GIT_TRACE=UNSET)
250
249
  #### 🔄 Reset Git envs by setting new values
251
250
 
252
251
  ```python
253
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
252
+ import gitbolt
254
253
 
255
- git = SimpleGitCommand()
254
+ git = gitbolt.get_git()
256
255
  overridden_git = git.git_envs_override(GIT_TRACE=True)
257
256
  git_trace_reset_git = overridden_git.git_envs_override(GIT_TRACE=False)
258
257
  ```
@@ -268,9 +267,9 @@ git_trace_reset_git = overridden_git.git_envs_override(GIT_TRACE=False)
268
267
  #### 🔁 Override a single Git opt (e.g., `--no-replace-objects`)
269
268
 
270
269
  ```python
271
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
270
+ import gitbolt
272
271
 
273
- git = SimpleGitCommand()
272
+ git = gitbolt.get_git()
274
273
  git = git.git_opts_override(no_replace_objects=True)
275
274
  ```
276
275
 
@@ -278,7 +277,7 @@ git = git.git_opts_override(no_replace_objects=True)
278
277
 
279
278
  ```python
280
279
  from pathlib import Path
281
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
280
+ from gitbolt.subprocess.impl.simple import SimpleGitCommand
282
281
 
283
282
  git = SimpleGitCommand()
284
283
  git = git.git_opts_override(no_replace_objects=True, git_dir=Path(), paginate=True)
@@ -287,10 +286,10 @@ git = git.git_opts_override(no_replace_objects=True, git_dir=Path(), paginate=Tr
287
286
  #### 🪢 Chain multiple option overrides fluently
288
287
 
289
288
  ```python
289
+ import gitbolt
290
290
  from pathlib import Path
291
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
292
291
 
293
- git = SimpleGitCommand()
292
+ git = gitbolt.get_git()
294
293
  overridden_git = git.git_opts_override(exec_path=Path('tmp')).git_opts_override(
295
294
  noglob_pathspecs=True,
296
295
  no_advice=True
@@ -303,11 +302,11 @@ re_overridden_git = overridden_git.git_opts_override(glob_pathspecs=True)
303
302
  #### ❌ Unset Git opts using a special `UNSET` marker
304
303
 
305
304
  ```python
305
+ import gitbolt
306
306
  from pathlib import Path
307
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
308
307
  from vt.utils.commons.commons.core_py import UNSET
309
308
 
310
- git = SimpleGitCommand()
309
+ git = gitbolt.get_git()
311
310
  overridden_git = git.git_opts_override(exec_path=Path('tmp'), no_advice=True)
312
311
  no_advice_unset_git = overridden_git.git_opts_override(no_advice=UNSET)
313
312
  ```
@@ -315,9 +314,9 @@ no_advice_unset_git = overridden_git.git_opts_override(no_advice=UNSET)
315
314
  #### 🔄 Reset Git opts by setting new values
316
315
 
317
316
  ```python
318
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
317
+ import gitbolt
319
318
 
320
- git = SimpleGitCommand()
319
+ git = gitbolt.get_git()
321
320
  overridden_git = git.git_opts_override(no_advice=True)
322
321
  no_advice_reset_git = overridden_git.git_opts_override(no_advice=False)
323
322
  ```
@@ -333,9 +332,9 @@ Introduced in `0.0.0dev4` to
333
332
  - have consistent interfaced commands run until all subcommands are provided by the library.
334
333
 
335
334
  ```python
336
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
335
+ import gitbolt
337
336
 
338
- git = SimpleGitCommand()
337
+ git = gitbolt.get_git_command()
339
338
  git = git.git_opts_override(no_advice=True)
340
339
  git.subcmd_unchecked.run(['--version']) # run the version option for git.
341
340
  git.subcmd_unchecked.run(['version']) # run the version subcommand.
@@ -350,11 +349,11 @@ would be to make a system that receives CLI commands and does certain modificati
350
349
  actually running them. An example:
351
350
 
352
351
  ```python
353
- from gitbolt.git_subprocess.impl.simple import CLISimpleGitCommand
352
+ import gitbolt
354
353
 
355
- opts = ["--no-pager", "--namespace", "n1"] # options received from outside your program.
356
- envs = dict(GIT_AUTHOR_NAME="ss") # env-vars received form outside your program.
357
- git = CLISimpleGitCommand(opts=opts, envs=envs)
354
+ opts = ["--no-pager", "--namespace", "n1"] # options received from outside your program.
355
+ envs = dict(GIT_AUTHOR_NAME="ss") # env-vars received form outside your program.
356
+ git = gitbolt.get_git_command(opts=opts, envs=envs)
358
357
 
359
358
  # these can later be overridden
360
359
  git = git.git_opts_override(namespace="n2")
@@ -0,0 +1,33 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/gitbolt/__init__.py
5
+ src/gitbolt/_internal_init.py
6
+ src/gitbolt/add.py
7
+ src/gitbolt/base.py
8
+ src/gitbolt/constants.py
9
+ src/gitbolt/exceptions.py
10
+ src/gitbolt/ls_tree.py
11
+ src/gitbolt/models.py
12
+ src/gitbolt/py.typed
13
+ src/gitbolt/pytest_plugin.py
14
+ src/gitbolt/utils.py
15
+ src/gitbolt.egg-info/PKG-INFO
16
+ src/gitbolt.egg-info/SOURCES.txt
17
+ src/gitbolt.egg-info/dependency_links.txt
18
+ src/gitbolt.egg-info/entry_points.txt
19
+ src/gitbolt.egg-info/requires.txt
20
+ src/gitbolt.egg-info/top_level.txt
21
+ src/gitbolt/subprocess/__init__.py
22
+ src/gitbolt/subprocess/_internal_init.py
23
+ src/gitbolt/subprocess/add.py
24
+ src/gitbolt/subprocess/base.py
25
+ src/gitbolt/subprocess/constants.py
26
+ src/gitbolt/subprocess/exceptions.py
27
+ src/gitbolt/subprocess/ls_tree.py
28
+ src/gitbolt/subprocess/utils.py
29
+ src/gitbolt/subprocess/impl/__init__.py
30
+ src/gitbolt/subprocess/impl/simple.py
31
+ src/gitbolt/subprocess/runner/__init__.py
32
+ src/gitbolt/subprocess/runner/base.py
33
+ src/gitbolt/subprocess/runner/simple.py
@@ -1,4 +1,4 @@
1
- vt-err-hndlr>=0.0.0dev5
1
+ vt-err-hndlr>=0.0.0dev6
2
2
  vt-commons>=0.0.1.dev9
3
3
 
4
4
  [pygit2]
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env python3
2
- # coding=utf-8
3
-
4
- """
5
- Git command interfaces with default implementation using subprocess calls.
6
- """
7
-
8
- from pathlib import Path
9
-
10
- # region imports
11
- # region base related imports
12
- from gitbolt.base import Git as Git
13
- from gitbolt.base import CanOverrideGitOpts as CanOverrideGitOpts
14
- from gitbolt.base import HasGitUnderneath as HasGitUnderneath
15
- from gitbolt.base import GitSubCommand as GitSubCommand
16
- from gitbolt.base import LsTree as LsTree
17
- from gitbolt.base import Version as Version
18
- from gitbolt.base import Add as Add
19
- # endregion
20
-
21
-
22
- from gitbolt.constants import GIT_DIR as GIT_DIR
23
- # endregion
24
-
25
-
26
- def get_git(git_root_dir: Path = Path.cwd()) -> Git:
27
- """
28
- Get operational and programmatic ``Git``.
29
-
30
- Examples:
31
-
32
- * Get git version:
33
-
34
- >>> import subprocess
35
- >>> import gitbolt
36
- >>> git = gitbolt.get_git()
37
- >>> assert git.version().version() == subprocess.run(['git', 'version'], capture_output=True, text=True).stdout.strip()
38
-
39
- :param git_root_dir: Path to the git repo root directory. Defaults to current working directory.
40
- """
41
- from gitbolt.git_subprocess.impl.simple import SimpleGitCommand
42
-
43
- return SimpleGitCommand(git_root_dir)
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env python3
2
- # coding=utf-8
3
-
4
- """
5
- Git command interfaces with implementation using subprocess calls.
6
- """
7
-
8
- # region gitbolt.git_subprocess.base
9
- from gitbolt.git_subprocess.base import GitCommand as GitCommand
10
- from gitbolt.git_subprocess.base import GitSubcmdCommand as GitSubcmdCommand
11
- from gitbolt.git_subprocess.base import AddCommand as AddCommand
12
- from gitbolt.git_subprocess.base import LsTreeCommand as LsTreeCommand
13
- from gitbolt.git_subprocess.base import VersionCommand as VersionCommand
14
- from gitbolt.git_subprocess.base import UncheckedSubcmd as UncheckedSubcmd
15
- # endregion
@@ -1,33 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- src/gitbolt/__init__.py
5
- src/gitbolt/_internal_init.py
6
- src/gitbolt/add.py
7
- src/gitbolt/base.py
8
- src/gitbolt/constants.py
9
- src/gitbolt/exceptions.py
10
- src/gitbolt/ls_tree.py
11
- src/gitbolt/models.py
12
- src/gitbolt/py.typed
13
- src/gitbolt/pytest_plugin.py
14
- src/gitbolt/utils.py
15
- src/gitbolt.egg-info/PKG-INFO
16
- src/gitbolt.egg-info/SOURCES.txt
17
- src/gitbolt.egg-info/dependency_links.txt
18
- src/gitbolt.egg-info/entry_points.txt
19
- src/gitbolt.egg-info/requires.txt
20
- src/gitbolt.egg-info/top_level.txt
21
- src/gitbolt/git_subprocess/__init__.py
22
- src/gitbolt/git_subprocess/_internal_init.py
23
- src/gitbolt/git_subprocess/add.py
24
- src/gitbolt/git_subprocess/base.py
25
- src/gitbolt/git_subprocess/constants.py
26
- src/gitbolt/git_subprocess/exceptions.py
27
- src/gitbolt/git_subprocess/ls_tree.py
28
- src/gitbolt/git_subprocess/utils.py
29
- src/gitbolt/git_subprocess/impl/__init__.py
30
- src/gitbolt/git_subprocess/impl/simple.py
31
- src/gitbolt/git_subprocess/runner/__init__.py
32
- src/gitbolt/git_subprocess/runner/base.py
33
- src/gitbolt/git_subprocess/runner/simple_impl.py
File without changes
File without changes