gitbolt 0.0.0.dev1__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/models.py ADDED
@@ -0,0 +1,686 @@
1
+ #!/usr/bin/env python3
2
+ # coding=utf-8
3
+
4
+ """
5
+ models and datatypes related to git and git subcommands.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from datetime import datetime
11
+ from pathlib import Path
12
+ from typing import TypedDict, Sequence, Literal
13
+
14
+ from vt.utils.commons.commons.core_py import Unset
15
+
16
+
17
+ # git main command options
18
+ class GitOpts(TypedDict, total=False):
19
+ """
20
+ All the parameters are mirrors of the options of the ``git`` CLI command
21
+ from `git documentation <https://git-scm.com/docs/git>`_.
22
+
23
+ These options are applied before any git subcommand (like ``log``, ``commit``, etc.).
24
+
25
+ For example, in ``git --no-pager log -1 master`` git command, ``--no-pager`` is the main command option.
26
+ """
27
+
28
+ C: Sequence[Path] | Unset | None
29
+ """
30
+ Mirror of ``-C <path>``.
31
+
32
+ Run as if git was started in the specified path(s) instead of the current working directory.
33
+ Can be specified multiple times.
34
+
35
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt--Cltpathgt>`_.
36
+ """
37
+
38
+ c: dict[str, str | bool | None | Unset] | None | Unset
39
+ """
40
+ Mirror of ``-c <name>=<value>``.
41
+
42
+ Sets a configuration variable for the duration of the git command.
43
+ Equivalent to using ``git config`` temporarily.
44
+
45
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt--cltnamegtltvaluegt>`_.
46
+ """
47
+
48
+ config_env: dict[str, str] | None | Unset
49
+ """
50
+ Mirror of ``--config-env=<name>=<env-var>``.
51
+
52
+ Set configuration variables from environment variables, useful in environments where configuration is set externally.
53
+
54
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---config-envltnamegtltenvvargt>`_.
55
+ """
56
+
57
+ exec_path: Path | None | Unset
58
+ """
59
+ Mirror of ``--exec-path[=<path>]``.
60
+
61
+ Path to the directory where git-core executables are located.
62
+ If not set, uses the default from the environment or compiled-in path.
63
+
64
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---exec-pathltpathgt>`_.
65
+ """
66
+
67
+ paginate: bool | None | Unset
68
+ """
69
+ Mirror of ``--paginate``.
70
+
71
+ Forces git to use a pager for output, even if stdout is not a terminal.
72
+
73
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---paginate>`_.
74
+ """
75
+
76
+ no_pager: bool | None | Unset
77
+ """
78
+ Mirror of ``--no-pager``.
79
+
80
+ Disables the use of a pager for output.
81
+
82
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---no-pager>`_.
83
+ """
84
+
85
+ git_dir: Path | None | Unset
86
+ """
87
+ Mirror of ``--git-dir=<path>``.
88
+
89
+ Sets the path to the git repository (i.e., the ``.git`` directory).
90
+
91
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt>`_.
92
+ """
93
+
94
+ work_tree: Path | None | Unset
95
+ """
96
+ Mirror of ``--work-tree=<path>``.
97
+
98
+ Sets the working tree root for the repository.
99
+
100
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---work-treeltpathgt>`_.
101
+ """
102
+
103
+ namespace: str | None | Unset
104
+ """
105
+ Mirror of ``--namespace=<namespace>``.
106
+
107
+ Sets the git namespace for refs, useful in server environments or special ref layouts.
108
+
109
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---namespaceltpathgt>`_.
110
+ """
111
+
112
+ bare: bool | None | Unset
113
+ """
114
+ Mirror of ``--bare``.
115
+
116
+ Treat the repository as a bare repository.
117
+
118
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---bare>`_.
119
+ """
120
+
121
+ no_replace_objects: bool | None | Unset
122
+ """
123
+ Mirror of ``--no-replace-objects``.
124
+
125
+ Disables use of replacement objects that might otherwise override objects in the repo.
126
+
127
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---no-replace-objects>`_.
128
+ """
129
+
130
+ no_lazy_fetch: bool | None | Unset
131
+ """
132
+ Mirror of ``--no-lazy-fetch``.
133
+
134
+ Prevents git from auto-fetching missing objects on demand.
135
+ Introduced in newer git versions.
136
+
137
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---no-lazy-fetch>`_.
138
+ """
139
+
140
+ no_optional_locks: bool | None | Unset
141
+ """
142
+ Mirror of ``--no-optional-locks``.
143
+
144
+ Prevents git from taking optional locks (used for performance tuning).
145
+
146
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---no-optional-locks>`_.
147
+ """
148
+
149
+ no_advice: bool | None | Unset
150
+ """
151
+ Mirror of ``--no-advice``.
152
+
153
+ Suppresses all advice messages that git might normally print.
154
+
155
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---no-advice>`_.
156
+ """
157
+
158
+ literal_pathspecs: bool | None | Unset
159
+ """
160
+ Mirror of ``--literal-pathspecs``.
161
+
162
+ Treat pathspecs literally (no wildcards, no globbing).
163
+
164
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---literal-pathspecs>`_.
165
+ """
166
+
167
+ glob_pathspecs: bool | None | Unset
168
+ """
169
+ Mirror of ``--glob-pathspecs``.
170
+
171
+ Enable globbing in pathspecs.
172
+
173
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---glob-pathspecs>`_.
174
+ """
175
+
176
+ noglob_pathspecs: bool | None | Unset
177
+ """
178
+ Mirror of ``--noglob-pathspecs``.
179
+
180
+ Disable globbing for pathspecs.
181
+
182
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---noglob-pathspecs>`_.
183
+ """
184
+
185
+ icase_pathspecs: bool | None | Unset
186
+ """
187
+ Mirror of ``--icase-pathspecs``.
188
+
189
+ Makes pathspecs case-insensitive (useful on case-insensitive filesystems).
190
+
191
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---icase-pathspecs>`_.
192
+ """
193
+
194
+ list_cmds: Sequence[str] | None | Unset
195
+ """
196
+ Mirror of ``--list-cmds=<category>``.
197
+
198
+ Used to list available commands grouped by category.
199
+
200
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---list-cmdsltgroupgtltgroupgt82308203>`_.
201
+ """
202
+
203
+ attr_source: str | None | Unset
204
+ """
205
+ Mirror of ``--attr-source=<tree-ish>``.
206
+
207
+ Specifies the source tree for attribute lookups.
208
+
209
+ `Documented <https://git-scm.com/docs/git#Documentation/git.txt---attr-sourcelttree-ishgt>`_.
210
+ """
211
+
212
+
213
+ # region git env vars
214
+ class GitCommitEnvVars(TypedDict, total=False):
215
+ """
216
+ Env vars mirroring: https://git-scm.com/docs/git#_git_commits
217
+ """
218
+
219
+ GIT_AUTHOR_NAME: str | Unset
220
+ GIT_AUTHOR_EMAIL: str | Unset
221
+ GIT_AUTHOR_DATE: str | datetime | int | Unset
222
+ GIT_COMMITTER_NAME: str | Unset
223
+ GIT_COMMITTER_EMAIL: str | Unset
224
+ GIT_COMMITTER_DATE: str | datetime | int | Unset
225
+
226
+
227
+ class GitSysEnvVars(TypedDict, total=False):
228
+ """
229
+ Env vars mirroring: https://git-scm.com/docs/git#_system
230
+ """
231
+
232
+ HOME: Path | Unset
233
+
234
+
235
+ class GitEditorEnvVars(TypedDict, total=False):
236
+ """
237
+ Env vars mirroring: https://git-scm.com/docs/git#_system
238
+ """
239
+
240
+ GIT_EDITOR: str | Unset
241
+ GIT_PAGER: str | Unset
242
+
243
+
244
+ class GitSSHEnvVars(TypedDict, total=False):
245
+ """
246
+ Env vars mirroring: https://git-scm.com/docs/git#_system
247
+ """
248
+
249
+ GIT_SSH: Path | Unset
250
+ GIT_SSH_COMMAND: str | Unset
251
+
252
+
253
+ class GitTraceEnvVars(TypedDict, total=False):
254
+ """
255
+ Env vars mirroring: https://git-scm.com/docs/git#_system
256
+ """
257
+
258
+ GIT_TRACE: Literal[1, 2] | bool | Path | Unset
259
+ GIT_TRACE_SETUP: Literal[1, 2] | bool | Path | Unset
260
+ GIT_TRACE_PERFORMANCE: Literal[1, 2] | bool | Path | Unset
261
+ GIT_TRACE_PACKET: Literal[1, 2] | bool | Path | Unset
262
+
263
+
264
+ class GitConfigEnvVars(TypedDict, total=False):
265
+ """
266
+ Env vars mirroring: https://git-scm.com/docs/git#_system
267
+ """
268
+
269
+ GIT_CONFIG_NOSYSTEM: Literal[1] | bool | Unset
270
+ GIT_CONFIG_GLOBAL: Path | Unset
271
+ GIT_ADVICE: Literal[0] | bool | Unset
272
+
273
+
274
+ class GitRepoEnvVars(TypedDict, total=False):
275
+ """
276
+ Env vars mirroring: https://git-scm.com/docs/git#_the_git_repository
277
+ """
278
+
279
+ GIT_DIR: Path | Unset
280
+ GIT_WORK_TREE: Path | Unset
281
+ GIT_INDEX_FILE: Path | Unset
282
+ GIT_OBJECT_DIRECTORY: Path | Unset
283
+ GIT_ALTERNATE_OBJECT_DIRECTORIES: Path | Unset
284
+
285
+
286
+ class GitNetworkEnvVars(TypedDict, total=False):
287
+ """
288
+ Git network related env vars.
289
+ """
290
+
291
+ GIT_TERMINAL_PROMPT: Literal[0, 1] | bool | Unset
292
+ GIT_HTTP_USER_AGENT: str | Unset
293
+ GIT_HTTP_PROXY: str | Unset
294
+ GIT_HTTPS_PROXY: str | Unset
295
+ GIT_NO_REPLACE_OBJECTS: Literal[1] | bool | Unset
296
+
297
+
298
+ GIT_TRACE_TYPE = Literal[0] | bool | Literal[1, 2] | Path | Literal[3, 4, 5, 6, 7, 8, 9]
299
+ """
300
+ Takes values as declared in https://git-scm.com/docs/git#Documentation/git.txt-codeGITTRACEcode
301
+ """
302
+
303
+
304
+ class GitLogEnvVars(TypedDict, total=False):
305
+ """
306
+ Git environment variables related to git's internal debugging, logging, and performance tracing.
307
+
308
+ These allow developers and advanced users to inspect Git's internal behavior.
309
+ For details, see: https://git-scm.com/docs/git
310
+
311
+ All variables support:
312
+ - `False` or `0`: disabled
313
+ - `True` or 1–9: write trace to stderr
314
+ - `Path`: write trace to file
315
+ """
316
+
317
+ GIT_TRACE: GIT_TRACE_TYPE | Unset
318
+ """
319
+ General tracing facility.
320
+
321
+ Traces command execution, arguments, and key internal operations.
322
+ Docs: https://git-scm.com/docs/git#Documentation/git.txt-codeGITTRACEcode
323
+ """
324
+
325
+ GIT_TRACE_SETUP: GIT_TRACE_TYPE | Unset
326
+ """
327
+ Traces repository, environment, and config discovery setup.
328
+ Docs: https://git-scm.com/docs/git#Documentation/git.txt-codeGITTRACESETUPcode
329
+ """
330
+
331
+ GIT_TRACE_PACKET: GIT_TRACE_TYPE | Unset
332
+ """
333
+ Traces Git protocol packet communication (push, fetch, etc.).
334
+ Docs: https://git-scm.com/docs/git#Documentation/git.txt-codeGITTRACEPACKETcode
335
+ """
336
+
337
+ GIT_TRACE_PERFORMANCE: GIT_TRACE_TYPE | Unset
338
+ """
339
+ Logs performance data including timing metrics for Git operations.
340
+ Docs: https://git-scm.com/docs/git#Documentation/git.txt-codeGITTRACEPERFORMANCEcode
341
+ """
342
+
343
+ GIT_TRACE_PACK_ACCESS: GIT_TRACE_TYPE | Unset
344
+ """
345
+ Traces accesses to objects inside packfiles.
346
+ Docs: https://git-scm.com/docs/git#Documentation/git.txt-codeGITTRACEPACKACCESScode
347
+ """
348
+
349
+ GIT_TRACE_SHALLOW: GIT_TRACE_TYPE | Unset
350
+ """
351
+ Traces shallow clone logic and interaction with shallow files.
352
+ Docs: https://git-scm.com/docs/git#Documentation/git.txt-codeGITTRACESHALLOWcode
353
+ """
354
+
355
+ GIT_TRACE_CURL: GIT_TRACE_TYPE | Unset
356
+ """
357
+ Traces all libcurl activity used for HTTP/HTTPS communication.
358
+ Useful for diagnosing HTTPS issues.
359
+ Docs: https://git-scm.com/docs/git#Documentation/git.txt-codeGITTRACECURLcode
360
+ """
361
+
362
+ GIT_REDACT_COOKIES: str | Unset
363
+ """
364
+ Comma-separated list of cookie names to redact in curl trace logs.
365
+
366
+ Prevents sensitive information from appearing in trace logs.
367
+ Docs: https://git-scm.com/docs/git#Documentation/git.txt-codeGITREDACTCOOKIEScode
368
+ """
369
+
370
+
371
+ class GitEnvVars(
372
+ GitCommitEnvVars,
373
+ GitEditorEnvVars,
374
+ GitSSHEnvVars,
375
+ GitTraceEnvVars,
376
+ GitConfigEnvVars,
377
+ GitRepoEnvVars,
378
+ GitNetworkEnvVars,
379
+ GitSysEnvVars,
380
+ ):
381
+ """
382
+ Environment variables that control Git's runtime behavior.
383
+
384
+ These variables correspond to official Git environment variables
385
+ described in the Git documentation:
386
+
387
+ - General environment variables: https://git-scm.com/docs/git#_environment_variables
388
+ - Git Trace variables: https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables
389
+ - Git configuration environment variables: https://git-scm.com/docs/git-config#Documentation/git-config.txt
390
+
391
+ Each field corresponds to a known environment variable that influences
392
+ Git's operation or configuration during execution.
393
+
394
+ All variables are optional and can be set to control specific aspects
395
+ of Git's behavior.
396
+ """
397
+
398
+ pass
399
+
400
+
401
+ # endregion
402
+
403
+
404
+ # git add subcommand options
405
+ class GitAddOpts(TypedDict, total=False):
406
+ """
407
+ All the parameters mirror the options for the ``git add`` subcommand as described in the
408
+ official `git add documentation <https://git-scm.com/docs/git-add>`_.
409
+
410
+ These options allow fine-grained control over how files are staged in the Git index.
411
+
412
+ All options except:
413
+
414
+ * ``pathspec_from_file``: mimics ``--pathspec-from-file``.
415
+ * ``pathspec_file_nul``: mimics ``--pathspec-file-nul``
416
+ * ``pathspec``: mimics the [<pathspec>...] in documentation.
417
+ * ``pathspec_stdin``: stdin emulator, required when ``--pathspec-from-file`` is ``-`` (- is stdin).
418
+ """
419
+
420
+ verbose: bool
421
+ """
422
+ Mirror of ``--verbose``.
423
+
424
+ Show files as they are added.
425
+
426
+ Useful for tracking which files are being staged when using wildcard patterns or when adding many files.
427
+ """
428
+
429
+ dry_run: bool
430
+ """
431
+ Mirror of ``--dry-run``.
432
+
433
+ Show what would be done without actually performing the add.
434
+
435
+ No actual changes are made to the index.
436
+ """
437
+
438
+ force: bool
439
+ """
440
+ Mirror of ``--force`` or ``-f``.
441
+
442
+ Allow adding otherwise ignored files.
443
+
444
+ This is useful when a file is matched by `.gitignore` but still needs to be explicitly added.
445
+ """
446
+
447
+ interactive: bool
448
+ """
449
+ Mirror of ``--interactive`` or ``-i``.
450
+
451
+ Interactively choose hunks or files to stage.
452
+
453
+ Launches an interactive UI that allows selection of changes to be added.
454
+ """
455
+
456
+ patch: bool
457
+ """
458
+ Mirror of ``--patch`` or ``-p``.
459
+
460
+ Interactively choose hunks to stage in a patch-like UI.
461
+
462
+ Useful when you want to commit only parts of a file.
463
+ """
464
+
465
+ edit: bool
466
+ """
467
+ Mirror of ``--edit`` or ``-e``.
468
+
469
+ Open an editor to manually edit the diff being added.
470
+
471
+ Not commonly used outside specialized workflows.
472
+ """
473
+
474
+ no_all: bool | None
475
+ """
476
+ Mirror of ``--no-all`` or ``--all``.
477
+
478
+ Controls whether changes to tracked files not explicitly listed are added.
479
+
480
+ If ``True``, equivalent to ``--no-all`` (do not stage deletions).
481
+ If ``False``, equivalent to ``--all`` (stage deletions and modifications).
482
+ If ``None``, neither flag is passed.
483
+ """
484
+
485
+ no_ignore_removal: bool | None
486
+ """
487
+ Mirror of ``--no-ignore-removal`` or ``--ignore-removal``.
488
+
489
+ Controls whether ignored files that are removed should be staged as deletions.
490
+
491
+ If ``True``, equivalent to ``--no-ignore-removal``.
492
+ If ``False``, equivalent to ``--ignore-removal``.
493
+ If ``None``, neither flag is passed.
494
+ """
495
+
496
+ sparse: bool
497
+ """
498
+ Mirror of ``--sparse``.
499
+
500
+ Allow updating entries outside of the sparse-checkout cone.
501
+
502
+ Used with sparse checkouts to update entries not in the current working cone.
503
+ """
504
+
505
+ intent_to_add: bool
506
+ """
507
+ Mirror of ``--intent-to-add``.
508
+
509
+ Record an intent-to-add entry for a file that does not yet exist in the index.
510
+
511
+ Useful in partial clone scenarios or when you want to mark a file for future content.
512
+ """
513
+
514
+ refresh: bool
515
+ """
516
+ Mirror of ``--refresh``.
517
+
518
+ Refresh the index without actually adding files.
519
+
520
+ This updates the index's stat information to match the working tree.
521
+ """
522
+
523
+ ignore_errors: bool
524
+ """
525
+ Mirror of ``--ignore-errors``.
526
+
527
+ Continue adding files even if some files cannot be added.
528
+
529
+ Use with caution, as it may silently skip files with problems.
530
+ """
531
+
532
+ ignore_missing: bool
533
+ """
534
+ Mirror of ``--ignore-missing``.
535
+
536
+ Silently skip missing files instead of reporting an error.
537
+
538
+ Useful for scripting workflows where some files may not be present.
539
+ """
540
+
541
+ renormalize: bool
542
+ """
543
+ Mirror of ``--renormalize``.
544
+
545
+ Apply the current content filters (e.g., line endings) to staged files.
546
+
547
+ Useful after changing `.gitattributes` to ensure files are normalized properly.
548
+ """
549
+
550
+ chmod: Literal["+x", "-x"]
551
+ """
552
+ Mirror of ``--chmod={+x,-x}``.
553
+
554
+ Apply executable permission changes to added files.
555
+
556
+ ``+x`` makes the file executable, ``-x`` removes the executable bit.
557
+ """
558
+
559
+
560
+ class GitLsTreeOpts(TypedDict, total=False):
561
+ """
562
+ All the parameters mirror the options for the ``git ls-tree`` subcommand as described in the
563
+ official `git ls-tree documentation <https://git-scm.com/docs/git-ls-tree>`_.
564
+
565
+ These options allow introspection into the contents of a tree object in Git, including filtering,
566
+ formatting, and controlling recursion.
567
+
568
+ The required positional argument ``tree_ish`` (e.g., a commit, branch, or tree hash) is excluded from this dict.
569
+ """
570
+
571
+ d: bool
572
+ """
573
+ Mirror of ``-d``.
574
+
575
+ Show only the named tree entries themselves, not their children.
576
+
577
+ Useful for showing just directory entries at the current level, rather than listing all contents recursively.
578
+ """
579
+
580
+ r: bool
581
+ """
582
+ Mirror of ``-r``.
583
+
584
+ Recurse into sub-trees.
585
+
586
+ Allows the command to descend recursively into directories to show nested files.
587
+ """
588
+
589
+ t: bool
590
+ """
591
+ Mirror of ``-t``.
592
+
593
+ Show tree entries even when recursing.
594
+
595
+ Without this, only blobs (files) are shown when ``-r`` is used. With ``-t``, directory entries are shown too.
596
+ """
597
+
598
+ long: bool
599
+ """
600
+ Mirror of ``-l``.
601
+
602
+ Show object size and mode information (long listing format).
603
+
604
+ Includes blob size and extended information similar to ``ls -l`` in Unix.
605
+ """
606
+
607
+ z: bool
608
+ """
609
+ Mirror of ``-z``.
610
+
611
+ Output entries separated with NUL characters instead of newlines.
612
+
613
+ Useful when paths may contain special characters or when scripting.
614
+ """
615
+
616
+ name_only: bool
617
+ """
618
+ Mirror of ``--name-only``.
619
+
620
+ Show only the file names (without mode, type, object, or size).
621
+
622
+ Useful for extracting just the file paths from the tree object.
623
+ """
624
+
625
+ name_status: bool
626
+ """
627
+ Mirror of ``--name-status``.
628
+
629
+ Show the names and status of the objects in the tree (added, modified, deleted).
630
+
631
+ Useful for understanding the changes represented by the tree entries.
632
+ """
633
+
634
+ object_only: bool
635
+ """
636
+ Mirror of ``--object-only``.
637
+
638
+ Show only the object IDs (SHA1 hashes) of the tree entries.
639
+
640
+ Excludes path names and other metadata from output.
641
+ """
642
+
643
+ full_name: bool
644
+ """
645
+ Mirror of ``--full-name``.
646
+
647
+ Show full paths relative to the root of the tree.
648
+
649
+ This overrides Git’s default behavior of printing paths relative to the current working directory.
650
+ """
651
+
652
+ full_tree: bool
653
+ """
654
+ Mirror of ``--full-tree``.
655
+
656
+ Pretend as if the command is run from the root of the working tree.
657
+
658
+ This affects path filtering and is often used in scripts for predictable output.
659
+ """
660
+
661
+ abbrev: int
662
+ """
663
+ Mirror of ``--abbrev=<n>``.
664
+
665
+ Specify the number of digits for abbreviated object names (SHA1).
666
+
667
+ Git typically shortens object hashes in output; this controls the length explicitly.
668
+ """
669
+
670
+ format_: str
671
+ """
672
+ Mirror of ``--format=<format>``.
673
+
674
+ Customize the output format.
675
+
676
+ This is useful for scripting or processing structured output.
677
+ """
678
+
679
+ path: list[str]
680
+ """
681
+ Mimics the optional ``[--] <path>...`` component of the command.
682
+
683
+ Restrict the tree listing to specific paths or directories.
684
+
685
+ Works similarly to pathspec in other Git commands.
686
+ """
gitbolt/py.typed ADDED
File without changes