gitbolt 0.0.0.dev27__tar.gz → 0.0.1.dev2__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.
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/PKG-INFO +36 -3
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/README.md +33 -1
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/pyproject.toml +9 -3
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/base.py +267 -1
- gitbolt-0.0.1.dev2/src/gitbolt/hash_object.py +263 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/__init__.py +2 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/base.py +425 -2
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/constants.py +1 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/exceptions.py +4 -4
- gitbolt-0.0.1.dev2/src/gitbolt/subprocess/hash_object.py +227 -0
- gitbolt-0.0.1.dev2/src/gitbolt/subprocess/hash_object_util.py +90 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/impl/simple.py +95 -1
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/utils/session.py +83 -22
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/worktree.py +22 -19
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt.egg-info/PKG-INFO +36 -3
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt.egg-info/SOURCES.txt +3 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt.egg-info/requires.txt +1 -1
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/LICENSE +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/setup.cfg +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/__init__.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/_internal_init.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/add.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/constants.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/exceptions.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/ls_tree.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/models.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/py.typed +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/pytest_plugin.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/_internal_init.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/add.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/impl/__init__.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/ls_tree.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/runner/__init__.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/runner/base.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/runner/simple.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/utils/__init__.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/utils/main_cmd.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/subprocess/utils/models.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt/utils.py +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt.egg-info/dependency_links.txt +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/src/gitbolt.egg-info/entry_points.txt +0 -0
- {gitbolt-0.0.0.dev27 → gitbolt-0.0.1.dev2}/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.
|
|
3
|
+
Version: 0.0.1.dev2
|
|
4
4
|
Summary: Fast, flexible and type-safe Git commands in Python.
|
|
5
5
|
Author-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>, Thamotharan R <thamotharan.r@vaastav.tech>
|
|
6
6
|
Maintainer-email: Suhas Krishna Srivastava <suhas.srivastava@vaastav.tech>
|
|
@@ -8,6 +8,7 @@ License-Expression: Apache-2.0
|
|
|
8
8
|
Project-URL: homepage, https://github.com/Vaastav-Technologies/py-gitbolt
|
|
9
9
|
Project-URL: source, https://github.com/Vaastav-Technologies/py-gitbolt
|
|
10
10
|
Project-URL: issues, https://github.com/Vaastav-Technologies/py-gitbolt/issues
|
|
11
|
+
Project-URL: changelog, https://github.com/Vaastav-Technologies/py-gitbolt/blob/develop/CHANGELOG.md
|
|
11
12
|
Keywords: git,vcs,library,version control
|
|
12
13
|
Classifier: Development Status :: 1 - Planning
|
|
13
14
|
Classifier: Intended Audience :: Developers
|
|
@@ -27,7 +28,7 @@ Requires-Python: >=3.12
|
|
|
27
28
|
Description-Content-Type: text/markdown
|
|
28
29
|
License-File: LICENSE
|
|
29
30
|
Requires-Dist: vt-err-hndlr>=0.0.0dev6
|
|
30
|
-
Requires-Dist: vt-commons>=0.0.
|
|
31
|
+
Requires-Dist: vt-commons>=0.0.2.dev0
|
|
31
32
|
Provides-Extra: pygit2
|
|
32
33
|
Requires-Dist: pygit2; extra == "pygit2"
|
|
33
34
|
Provides-Extra: test
|
|
@@ -65,6 +66,7 @@ Dynamic: license-file
|
|
|
65
66
|
* 🧼 **Idiomatic Python:** Write commands in idiomatic Python at compile-time and be confident they’ll execute smoothly at runtime.
|
|
66
67
|
* 🎀 **Add-ons:** Special features provided to ease programming with git. These can be added if required.
|
|
67
68
|
* 💻 **CLI-cmd:** Take commands from cli and run in `gitbolt`.
|
|
69
|
+
* 🔐 **SHA-256:** Sessions support SHA-256 repositories.
|
|
68
70
|
|
|
69
71
|
---
|
|
70
72
|
|
|
@@ -108,6 +110,36 @@ Type-checking ensures runtime safety.
|
|
|
108
110
|
|
|
109
111
|
`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
112
|
|
|
113
|
+
Hashing a path or stdin does **not** require a repository. Writing objects (`-w`) does.
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from pathlib import Path
|
|
117
|
+
import gitbolt
|
|
118
|
+
|
|
119
|
+
git = gitbolt.get_git()
|
|
120
|
+
hash_object = git.hash_object_subcmd()
|
|
121
|
+
|
|
122
|
+
# Read-only: one file → one hash (no repository required).
|
|
123
|
+
blob_hash = hash_object.hash_object(Path("a-file"))
|
|
124
|
+
|
|
125
|
+
# Write the object into the repository (`-w`). Requires a repository.
|
|
126
|
+
written_hash = hash_object.writing().hash_object(Path("a-file"), w=True)
|
|
127
|
+
# Same writing command, obtained directly:
|
|
128
|
+
written_hash = git.writing_hash_object_subcmd().hash_object(Path("a-file"), w=True)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`multi_hash_objects` is a Gitbolt utility (Git has no such flag). Each stdin payload is written to a temp file and hashed in **one** `git hash-object` process:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
import gitbolt
|
|
135
|
+
|
|
136
|
+
git = gitbolt.get_git()
|
|
137
|
+
hashes = git.hash_object_subcmd().multi_hash_objects(b"from-a", b"from-b", b"from-c")
|
|
138
|
+
|
|
139
|
+
# Write those objects (`-w`) — requires a repository:
|
|
140
|
+
written = git.hash_object_subcmd().writing().multi_hash_objects(b"from-a", b"from-b", w=True)
|
|
141
|
+
```
|
|
142
|
+
|
|
111
143
|
#### Let subcommands be passed around as objects
|
|
112
144
|
|
|
113
145
|
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.
|
|
@@ -432,7 +464,8 @@ Transformers for formatting/parsing can be added later.
|
|
|
432
464
|
|
|
433
465
|
## Notes
|
|
434
466
|
|
|
435
|
-
|
|
467
|
+
- 0.0.1.dev1: Sessions support SHA-256 repositories.
|
|
468
|
+
- 0.0.0: `git hash-object` is available as `hash_object_subcmd()` / `writing_hash_object_subcmd()`. Use `writing()` (or `w=True`) to write objects; use `multi_hash_objects` to hash several stdin payloads in one process. Hashing works outside a repository; `-w` requires a repository.
|
|
436
469
|
- 0.0.0.dev24: `worktree` implementations are not stable yet. Use `subcmd_unchecked` directly.
|
|
437
470
|
|
|
438
471
|
---
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
* 🧼 **Idiomatic Python:** Write commands in idiomatic Python at compile-time and be confident they’ll execute smoothly at runtime.
|
|
30
30
|
* 🎀 **Add-ons:** Special features provided to ease programming with git. These can be added if required.
|
|
31
31
|
* 💻 **CLI-cmd:** Take commands from cli and run in `gitbolt`.
|
|
32
|
+
* 🔐 **SHA-256:** Sessions support SHA-256 repositories.
|
|
32
33
|
|
|
33
34
|
---
|
|
34
35
|
|
|
@@ -72,6 +73,36 @@ Type-checking ensures runtime safety.
|
|
|
72
73
|
|
|
73
74
|
`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.
|
|
74
75
|
|
|
76
|
+
Hashing a path or stdin does **not** require a repository. Writing objects (`-w`) does.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from pathlib import Path
|
|
80
|
+
import gitbolt
|
|
81
|
+
|
|
82
|
+
git = gitbolt.get_git()
|
|
83
|
+
hash_object = git.hash_object_subcmd()
|
|
84
|
+
|
|
85
|
+
# Read-only: one file → one hash (no repository required).
|
|
86
|
+
blob_hash = hash_object.hash_object(Path("a-file"))
|
|
87
|
+
|
|
88
|
+
# Write the object into the repository (`-w`). Requires a repository.
|
|
89
|
+
written_hash = hash_object.writing().hash_object(Path("a-file"), w=True)
|
|
90
|
+
# Same writing command, obtained directly:
|
|
91
|
+
written_hash = git.writing_hash_object_subcmd().hash_object(Path("a-file"), w=True)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`multi_hash_objects` is a Gitbolt utility (Git has no such flag). Each stdin payload is written to a temp file and hashed in **one** `git hash-object` process:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
import gitbolt
|
|
98
|
+
|
|
99
|
+
git = gitbolt.get_git()
|
|
100
|
+
hashes = git.hash_object_subcmd().multi_hash_objects(b"from-a", b"from-b", b"from-c")
|
|
101
|
+
|
|
102
|
+
# Write those objects (`-w`) — requires a repository:
|
|
103
|
+
written = git.hash_object_subcmd().writing().multi_hash_objects(b"from-a", b"from-b", w=True)
|
|
104
|
+
```
|
|
105
|
+
|
|
75
106
|
#### Let subcommands be passed around as objects
|
|
76
107
|
|
|
77
108
|
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.
|
|
@@ -396,7 +427,8 @@ Transformers for formatting/parsing can be added later.
|
|
|
396
427
|
|
|
397
428
|
## Notes
|
|
398
429
|
|
|
399
|
-
|
|
430
|
+
- 0.0.1.dev1: Sessions support SHA-256 repositories.
|
|
431
|
+
- 0.0.0: `git hash-object` is available as `hash_object_subcmd()` / `writing_hash_object_subcmd()`. Use `writing()` (or `w=True`) to write objects; use `multi_hash_objects` to hash several stdin payloads in one process. Hashing works outside a repository; `-w` requires a repository.
|
|
400
432
|
- 0.0.0.dev24: `worktree` implementations are not stable yet. Use `subcmd_unchecked` directly.
|
|
401
433
|
|
|
402
434
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "gitbolt"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.1.dev2"
|
|
4
4
|
description = "Fast, flexible and type-safe Git commands in Python."
|
|
5
5
|
requires-python = ">=3.12"
|
|
6
6
|
readme = "README.md"
|
|
@@ -38,7 +38,7 @@ classifiers = [
|
|
|
38
38
|
]
|
|
39
39
|
dependencies = [
|
|
40
40
|
"vt-err-hndlr >= 0.0.0dev6",
|
|
41
|
-
"vt-commons >= 0.0.
|
|
41
|
+
"vt-commons >= 0.0.2.dev0",
|
|
42
42
|
]
|
|
43
43
|
|
|
44
44
|
[project.optional-dependencies]
|
|
@@ -46,7 +46,7 @@ pygit2 = ['pygit2']
|
|
|
46
46
|
test = ['pytest']
|
|
47
47
|
|
|
48
48
|
[dependency-groups]
|
|
49
|
-
dev = ["mypy", "ruff"]
|
|
49
|
+
dev = ["mypy", "ruff==0.11.10"]
|
|
50
50
|
doc = ['sphinx', 'sphinx-argparse']
|
|
51
51
|
test = ["pytest", 'pytest-cov', "pytest-xdist"]
|
|
52
52
|
multitest = ['tox']
|
|
@@ -56,6 +56,7 @@ multitest = ['tox']
|
|
|
56
56
|
homepage = "https://github.com/Vaastav-Technologies/py-gitbolt"
|
|
57
57
|
source = "https://github.com/Vaastav-Technologies/py-gitbolt"
|
|
58
58
|
issues = "https://github.com/Vaastav-Technologies/py-gitbolt/issues"
|
|
59
|
+
changelog = "https://github.com/Vaastav-Technologies/py-gitbolt/blob/develop/CHANGELOG.md"
|
|
59
60
|
|
|
60
61
|
[tool.setuptools.packages.find]
|
|
61
62
|
where = ['src']
|
|
@@ -68,3 +69,8 @@ gitbolt_fixtures = "gitbolt.pytest_plugin"
|
|
|
68
69
|
# so let mypy try to best make sense of the data-types for pytest package
|
|
69
70
|
module = ["pytest.*"]
|
|
70
71
|
follow_untyped_imports = true
|
|
72
|
+
|
|
73
|
+
[tool.pytest.ini_options]
|
|
74
|
+
addopts = ["--doctest-modules", # Test all the doctests
|
|
75
|
+
"--doctest-glob=*.md", # Test doctests included as examples in the md files.
|
|
76
|
+
"--ignore=local-ai-plans"] # AI plans and research tests ignored.
|
|
@@ -20,6 +20,7 @@ from gitbolt.exceptions import GitExitingException
|
|
|
20
20
|
from gitbolt.models import GitOpts, GitAddOpts, GitLsTreeOpts, GitEnvVars
|
|
21
21
|
from gitbolt.ls_tree import LsTreeArgsValidator, UtilLsTreeArgsValidator
|
|
22
22
|
from gitbolt.add import AddArgsValidator, UtilAddArgsValidator
|
|
23
|
+
from gitbolt.hash_object import HashObjectArgsValidator, UtilHashObjectArgsValidator
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
class HasGitUnderneath[G: "Git"](Protocol):
|
|
@@ -224,7 +225,7 @@ class Version(GitSubCommand, Protocol):
|
|
|
224
225
|
Interface for ``git version`` command.
|
|
225
226
|
"""
|
|
226
227
|
|
|
227
|
-
class VersionInfo:
|
|
228
|
+
class VersionInfo(Protocol):
|
|
228
229
|
@abstractmethod
|
|
229
230
|
def version(self) -> str: ...
|
|
230
231
|
|
|
@@ -642,6 +643,257 @@ class Worktree(GitSubCommand, RootDirOp, Protocol):
|
|
|
642
643
|
return git.worktree_subcmd()
|
|
643
644
|
|
|
644
645
|
|
|
646
|
+
class HashObject(GitSubCommand, Protocol):
|
|
647
|
+
"""
|
|
648
|
+
Interface for ``git hash-object`` subcommand. Can only calculate hashes and does not write objects to git.
|
|
649
|
+
"""
|
|
650
|
+
|
|
651
|
+
# region hash_object and overloads
|
|
652
|
+
@overload
|
|
653
|
+
@abstractmethod
|
|
654
|
+
def hash_object(self, file_path: Path, *, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
655
|
+
path: Path | None = None, literally: bool = False) -> str:
|
|
656
|
+
"""
|
|
657
|
+
Compute the object ID of a file without writing it to the object database.
|
|
658
|
+
|
|
659
|
+
Mirrors ``git hash-object`` from `git hash-object documentation <https://git-scm.com/docs/git-hash-object>`_.
|
|
660
|
+
|
|
661
|
+
:param file_path: Path of the file to hash.
|
|
662
|
+
:param t: Object type (``blob``, ``commit``, ``tree``, or ``tag``).
|
|
663
|
+
:param path: Virtual path used to select attributes and filters.
|
|
664
|
+
:param literally: Allow an object type that would otherwise fail fsck.
|
|
665
|
+
:return: Object hash.
|
|
666
|
+
"""
|
|
667
|
+
...
|
|
668
|
+
|
|
669
|
+
@overload
|
|
670
|
+
@abstractmethod
|
|
671
|
+
def hash_object(self, file_path: Path, *, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
672
|
+
no_filters: bool = False, literally: bool = False) -> str:
|
|
673
|
+
"""
|
|
674
|
+
Compute the object ID of a file without writing it to the object database.
|
|
675
|
+
|
|
676
|
+
``path`` and ``no_filters`` cannot be combined.
|
|
677
|
+
|
|
678
|
+
:param file_path: Path of the file to hash.
|
|
679
|
+
:param t: Object type (``blob``, ``commit``, ``tree``, or ``tag``).
|
|
680
|
+
:param no_filters: Hash the file as-is, without converting CRLF or applying filters.
|
|
681
|
+
:param literally: Allow an object type that would otherwise fail fsck.
|
|
682
|
+
:return: Object hash.
|
|
683
|
+
"""
|
|
684
|
+
...
|
|
685
|
+
|
|
686
|
+
@overload
|
|
687
|
+
@abstractmethod
|
|
688
|
+
def hash_object(self, file_path: Path, *file_paths: Path, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
689
|
+
no_filters: bool = False, literally: bool = False, stdin: bytes | None = None) -> list[str]:
|
|
690
|
+
"""
|
|
691
|
+
Compute object IDs for one or more files, optionally hashing ``stdin`` first.
|
|
692
|
+
|
|
693
|
+
:param file_path: First file to hash.
|
|
694
|
+
:param file_paths: Additional files to hash in the same invocation.
|
|
695
|
+
:param t: Object type (``blob``, ``commit``, ``tree``, or ``tag``).
|
|
696
|
+
:param no_filters: Hash files as-is, without converting CRLF or applying filters.
|
|
697
|
+
:param literally: Allow an object type that would otherwise fail fsck.
|
|
698
|
+
:param stdin: Optional bytes hashed with ``--stdin`` before the files.
|
|
699
|
+
:return: Object hashes, one per hashed input.
|
|
700
|
+
"""
|
|
701
|
+
...
|
|
702
|
+
|
|
703
|
+
@overload
|
|
704
|
+
@abstractmethod
|
|
705
|
+
def hash_object(self, file_path: Path, *file_paths: Path, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
706
|
+
path: Path | None = None, literally: bool = False, stdin: bytes | None = None) -> list[str]:
|
|
707
|
+
"""
|
|
708
|
+
Compute object IDs for one or more files, optionally hashing ``stdin`` first.
|
|
709
|
+
|
|
710
|
+
``path`` and ``no_filters`` cannot be combined.
|
|
711
|
+
|
|
712
|
+
:param file_path: First file to hash.
|
|
713
|
+
:param file_paths: Additional files to hash in the same invocation.
|
|
714
|
+
:param t: Object type (``blob``, ``commit``, ``tree``, or ``tag``).
|
|
715
|
+
:param path: Virtual path used to select attributes and filters.
|
|
716
|
+
:param literally: Allow an object type that would otherwise fail fsck.
|
|
717
|
+
:param stdin: Optional bytes hashed with ``--stdin`` before the files.
|
|
718
|
+
:return: Object hashes, one per hashed input.
|
|
719
|
+
"""
|
|
720
|
+
...
|
|
721
|
+
|
|
722
|
+
@overload
|
|
723
|
+
@abstractmethod
|
|
724
|
+
def hash_object(self, *, stdin: bytes, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
725
|
+
path: Path | None = None, literally: bool = False) -> str:
|
|
726
|
+
"""
|
|
727
|
+
Compute the object ID of bytes from standard input.
|
|
728
|
+
|
|
729
|
+
:param stdin: Bytes to hash with ``--stdin``.
|
|
730
|
+
:param t: Object type (``blob``, ``commit``, ``tree``, or ``tag``).
|
|
731
|
+
:param path: Virtual path used to select attributes and filters.
|
|
732
|
+
:param literally: Allow an object type that would otherwise fail fsck.
|
|
733
|
+
:return: Object hash.
|
|
734
|
+
"""
|
|
735
|
+
...
|
|
736
|
+
|
|
737
|
+
@overload
|
|
738
|
+
@abstractmethod
|
|
739
|
+
def hash_object(self, *, stdin: bytes, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
740
|
+
no_filters: bool = False, literally: bool = False) -> str:
|
|
741
|
+
"""
|
|
742
|
+
Compute the object ID of bytes from standard input.
|
|
743
|
+
|
|
744
|
+
``path`` and ``no_filters`` cannot be combined.
|
|
745
|
+
|
|
746
|
+
:param stdin: Bytes to hash with ``--stdin``.
|
|
747
|
+
:param t: Object type (``blob``, ``commit``, ``tree``, or ``tag``).
|
|
748
|
+
:param no_filters: Hash the bytes as-is, without converting CRLF or applying filters.
|
|
749
|
+
:param literally: Allow an object type that would otherwise fail fsck.
|
|
750
|
+
:return: Object hash.
|
|
751
|
+
"""
|
|
752
|
+
...
|
|
753
|
+
|
|
754
|
+
@overload
|
|
755
|
+
@abstractmethod
|
|
756
|
+
def hash_object(self, *, stdin_paths: list[Path],
|
|
757
|
+
t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
758
|
+
no_filters: bool = False, literally: bool = False) -> list[str]:
|
|
759
|
+
"""
|
|
760
|
+
Compute object IDs for paths read from standard input.
|
|
761
|
+
|
|
762
|
+
``stdin_paths`` cannot be combined with file paths, ``stdin``, or ``path``.
|
|
763
|
+
|
|
764
|
+
:param stdin_paths: Paths hashed with ``--stdin-paths``.
|
|
765
|
+
:param t: Object type (``blob``, ``commit``, ``tree``, or ``tag``).
|
|
766
|
+
:param no_filters: Hash files as-is, without converting CRLF or applying filters.
|
|
767
|
+
:param literally: Allow an object type that would otherwise fail fsck.
|
|
768
|
+
:return: Object hashes, one per path.
|
|
769
|
+
"""
|
|
770
|
+
...
|
|
771
|
+
|
|
772
|
+
@abstractmethod
|
|
773
|
+
def multi_hash_objects(self, stdin: bytes, *stdins: bytes,
|
|
774
|
+
t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
775
|
+
no_filters: bool = False, literally: bool = False,
|
|
776
|
+
tmpdir: Path | None = None) -> list[str]:
|
|
777
|
+
"""
|
|
778
|
+
Hash multiple stdin payloads in one ``git hash-object`` process.
|
|
779
|
+
|
|
780
|
+
This is a GitBolt utility method. Git ``hash-object`` has no ``multi_hash_objects``
|
|
781
|
+
subcommand or flag; each stdin is written to a temporary file and those paths are
|
|
782
|
+
hashed together in a single process.
|
|
783
|
+
If ``tmpdir`` is omitted, a temporary directory is created and cleaned up.
|
|
784
|
+
|
|
785
|
+
:param stdin: First bytes payload to hash.
|
|
786
|
+
:param stdins: Additional bytes payloads to hash.
|
|
787
|
+
:param t: Object type (``blob``, ``commit``, ``tree``, or ``tag``).
|
|
788
|
+
:param no_filters: Hash files as-is, without converting CRLF or applying filters.
|
|
789
|
+
:param literally: Allow an object type that would otherwise fail fsck.
|
|
790
|
+
:param tmpdir: Directory for the temporary files. Created when omitted.
|
|
791
|
+
:return: Object hashes, one per stdin payload.
|
|
792
|
+
"""
|
|
793
|
+
...
|
|
794
|
+
# endregion
|
|
795
|
+
|
|
796
|
+
@override
|
|
797
|
+
def _subcmd_from_git(self, git: 'Git') -> HashObject:
|
|
798
|
+
return git.hash_object_subcmd()
|
|
799
|
+
|
|
800
|
+
def args_validator(self) -> HashObjectArgsValidator:
|
|
801
|
+
"""
|
|
802
|
+
The argument validator for ``git hash-object`` subcommand.
|
|
803
|
+
|
|
804
|
+
:return: a validator for hash_object subcommand arguments.
|
|
805
|
+
"""
|
|
806
|
+
return UtilHashObjectArgsValidator()
|
|
807
|
+
|
|
808
|
+
@abstractmethod
|
|
809
|
+
def writing(self) -> WritingHashObject:
|
|
810
|
+
"""
|
|
811
|
+
:return: ``git hash-object`` subcommand which can write objects to git.
|
|
812
|
+
"""
|
|
813
|
+
...
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
class WritingHashObject(HashObject, RootDirOp, Protocol):
|
|
817
|
+
"""
|
|
818
|
+
Interface for ``git hash-object`` subcommand which can write objects to git.
|
|
819
|
+
"""
|
|
820
|
+
|
|
821
|
+
# region hash_object and overloads
|
|
822
|
+
@overload
|
|
823
|
+
@abstractmethod
|
|
824
|
+
def hash_object(self, file_path: Path, *, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
825
|
+
path: Path | None = None, literally: bool = False, w: bool = False) -> str:
|
|
826
|
+
...
|
|
827
|
+
|
|
828
|
+
@overload
|
|
829
|
+
@abstractmethod
|
|
830
|
+
def hash_object(self, file_path: Path, *, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
831
|
+
no_filters: bool = False, literally: bool = False, w: bool = False) -> str:
|
|
832
|
+
...
|
|
833
|
+
|
|
834
|
+
@overload
|
|
835
|
+
@abstractmethod
|
|
836
|
+
def hash_object(self, file_path: Path, *file_paths: Path, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
837
|
+
no_filters: bool = False, literally: bool = False, stdin: bytes | None = None,
|
|
838
|
+
w: bool = False) -> list[str]:
|
|
839
|
+
...
|
|
840
|
+
|
|
841
|
+
@overload
|
|
842
|
+
@abstractmethod
|
|
843
|
+
def hash_object(self, file_path: Path, *file_paths: Path, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
844
|
+
path: Path | None = None, literally: bool = False, stdin: bytes | None = None,
|
|
845
|
+
w: bool = False) -> list[str]:
|
|
846
|
+
...
|
|
847
|
+
|
|
848
|
+
@overload
|
|
849
|
+
@abstractmethod
|
|
850
|
+
def hash_object(self, *, stdin: bytes, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
851
|
+
path: Path | None = None, literally: bool = False, w: bool = False) -> str:
|
|
852
|
+
...
|
|
853
|
+
|
|
854
|
+
@overload
|
|
855
|
+
@abstractmethod
|
|
856
|
+
def hash_object(self, *, stdin: bytes, t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
857
|
+
no_filters: bool = False, literally: bool = False, w: bool = False) -> str:
|
|
858
|
+
...
|
|
859
|
+
|
|
860
|
+
@overload
|
|
861
|
+
@abstractmethod
|
|
862
|
+
def hash_object(self, *, stdin_paths: list[Path],
|
|
863
|
+
t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
864
|
+
no_filters: bool = False, literally: bool = False, w: bool = False) -> list[str]:
|
|
865
|
+
...
|
|
866
|
+
|
|
867
|
+
@override
|
|
868
|
+
@abstractmethod
|
|
869
|
+
def multi_hash_objects(self, stdin: bytes, *stdins: bytes,
|
|
870
|
+
t: Literal["commit", "tree", "blob", "tag"] = "blob",
|
|
871
|
+
no_filters: bool = False, literally: bool = False, w: bool = False,
|
|
872
|
+
tmpdir: Path | None = None) -> list[str]:
|
|
873
|
+
"""
|
|
874
|
+
Hash multiple stdin payloads in one ``git hash-object`` process.
|
|
875
|
+
|
|
876
|
+
This is a GitBolt utility method. Git ``hash-object`` has no ``multi_hash_objects``
|
|
877
|
+
subcommand or flag.
|
|
878
|
+
|
|
879
|
+
:param stdin: First bytes payload to hash.
|
|
880
|
+
:param stdins: Additional bytes payloads to hash.
|
|
881
|
+
:param t: Object type (``blob``, ``commit``, ``tree``, or ``tag``).
|
|
882
|
+
:param no_filters: Hash files as-is, without converting CRLF or applying filters.
|
|
883
|
+
:param literally: Allow an object type that would otherwise fail fsck.
|
|
884
|
+
:param w: Write the resulting objects into the object database.
|
|
885
|
+
:param tmpdir: Directory for the temporary files. Created when omitted.
|
|
886
|
+
:return: Object hashes, one per stdin payload.
|
|
887
|
+
"""
|
|
888
|
+
...
|
|
889
|
+
|
|
890
|
+
# endregion
|
|
891
|
+
|
|
892
|
+
@override
|
|
893
|
+
def _subcmd_from_git(self, git: 'Git') -> WritingHashObject:
|
|
894
|
+
return git.writing_hash_object_subcmd()
|
|
895
|
+
|
|
896
|
+
|
|
645
897
|
class Git(CanOverrideGitOpts, CanOverrideGitEnvs, Protocol):
|
|
646
898
|
"""
|
|
647
899
|
Class designed analogous to documentation provided on `git documentation <https://git-scm.com/docs/git>`_.
|
|
@@ -702,6 +954,20 @@ class Git(CanOverrideGitOpts, CanOverrideGitEnvs, Protocol):
|
|
|
702
954
|
"""
|
|
703
955
|
...
|
|
704
956
|
|
|
957
|
+
@abstractmethod
|
|
958
|
+
def hash_object_subcmd(self) -> HashObject:
|
|
959
|
+
"""
|
|
960
|
+
:return: ``git hash-object`` subcommand. Can calculate hashes but cannot write objects to the git database.
|
|
961
|
+
"""
|
|
962
|
+
...
|
|
963
|
+
|
|
964
|
+
@abstractmethod
|
|
965
|
+
def writing_hash_object_subcmd(self) -> WritingHashObject:
|
|
966
|
+
"""
|
|
967
|
+
:return: ``git hash-object`` subcommand. Can write objects to the git database.
|
|
968
|
+
"""
|
|
969
|
+
...
|
|
970
|
+
|
|
705
971
|
@abstractmethod
|
|
706
972
|
def worktree_subcmd(self) -> Worktree:
|
|
707
973
|
"""
|