gitbolt 0.0.0.dev26__py3-none-any.whl → 0.0.1.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/base.py CHANGED
@@ -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
  """
gitbolt/hash_object.py ADDED
@@ -0,0 +1,263 @@
1
+ #!/usr/bin/env python3
2
+ # coding=utf-8
3
+
4
+ """
5
+ Helper interfaces specific to ``git hash-object`` subcommand.
6
+ """
7
+
8
+ from abc import abstractmethod
9
+ from pathlib import Path
10
+ from typing import Protocol, override, Literal
11
+
12
+ from gitbolt._internal_init import errmsg_creator
13
+ from gitbolt.exceptions import GitExitingException
14
+ from vt.utils.commons.commons.core_py import has_atleast_one_arg
15
+ from vt.utils.errors.error_specs import ERR_DATA_FORMAT_ERR, ERR_INVALID_USAGE
16
+ from vt.utils.errors.error_specs.utils import require_type, require_iterable
17
+
18
+ _HASH_OBJECT_TYPES = ("commit", "tree", "blob", "tag")
19
+
20
+
21
+ class HashObjectArgsValidator(Protocol):
22
+ """
23
+ The argument validator for ``git hash-object`` subcommand.
24
+ """
25
+
26
+ @abstractmethod
27
+ def validate(
28
+ self,
29
+ file_path: Path | None = None,
30
+ *file_paths: Path,
31
+ t: Literal["commit", "tree", "blob", "tag"] = "blob",
32
+ path: Path | None = None,
33
+ no_filters: bool = False,
34
+ literally: bool = False,
35
+ stdin: bytes | None = None,
36
+ stdin_paths: list[Path] | None = None,
37
+ w: bool = False,
38
+ ) -> None:
39
+ """
40
+ Validate the inputs provided to the ``git hash-object`` command.
41
+
42
+ Either a file path or stdin must be present. ``stdin_paths`` counts as stdin
43
+ because Git reads those paths from standard input.
44
+
45
+ :raises GitExitingException: When validation fails.
46
+ """
47
+ ...
48
+
49
+
50
+ class UtilHashObjectArgsValidator(HashObjectArgsValidator):
51
+ """
52
+ Independent utility function sort of interface to perform hash_object() arguments validation.
53
+ """
54
+
55
+ @override
56
+ def validate(
57
+ self,
58
+ file_path: Path | None = None,
59
+ *file_paths: Path,
60
+ t: Literal["commit", "tree", "blob", "tag"] = "blob",
61
+ path: Path | None = None,
62
+ no_filters: bool = False,
63
+ literally: bool = False,
64
+ stdin: bytes | None = None,
65
+ stdin_paths: list[Path] | None = None,
66
+ w: bool = False,
67
+ ) -> None:
68
+ """
69
+ Validate the inputs provided to the ``git hash-object`` command.
70
+
71
+ This includes:
72
+
73
+ * Either a file path or stdin must be present. ``stdin_paths`` is stdin.
74
+ * ``file_path`` / extra file paths cannot be combined with ``stdin_paths``.
75
+ * ``stdin`` cannot be combined with ``stdin_paths``.
76
+ * ``path`` cannot be combined with ``no_filters``.
77
+ * ``path`` cannot be combined with ``stdin_paths``.
78
+ * Types for ``Path``, ``list[Path]``, object type literal, bools, and ``bytes``.
79
+
80
+ All validations will raise a ``GitExitingException`` with a specific exit code:
81
+
82
+ * ``TypeError`` leads to ``ERR_DATA_FORMAT_ERR``.
83
+ * ``ValueError`` leads to ``ERR_INVALID_USAGE``.
84
+
85
+ See: `git hash-object documentation <https://git-scm.com/docs/git-hash-object>`_.
86
+
87
+ Examples::
88
+
89
+ >>> UtilHashObjectArgsValidator().validate(Path("README.md"))
90
+ >>> UtilHashObjectArgsValidator().validate(Path("a.txt"), Path("b.txt"), no_filters=True)
91
+ >>> UtilHashObjectArgsValidator().validate(stdin=b"blob-bytes")
92
+ >>> UtilHashObjectArgsValidator().validate(stdin_paths=[Path("a.txt")])
93
+ >>> UtilHashObjectArgsValidator().validate(Path("a.txt"), path=Path("filters/a.txt"))
94
+ >>> UtilHashObjectArgsValidator().validate(Path("a.txt"), t="commit", literally=True, w=True)
95
+
96
+ Invalid Examples::
97
+
98
+ >>> UtilHashObjectArgsValidator().validate()
99
+ Traceback (most recent call last):
100
+ gitbolt.exceptions.GitExitingException: ValueError: Either file_path or stdin is required
101
+
102
+ >>> UtilHashObjectArgsValidator().validate(Path("a.txt"), stdin_paths=[Path("b.txt")])
103
+ Traceback (most recent call last):
104
+ gitbolt.exceptions.GitExitingException: ValueError: file_path and stdin_paths are not allowed together
105
+
106
+ >>> UtilHashObjectArgsValidator().validate(stdin=b"x", stdin_paths=[Path("a.txt")])
107
+ Traceback (most recent call last):
108
+ gitbolt.exceptions.GitExitingException: ValueError: stdin and stdin_paths are not allowed together
109
+
110
+ >>> UtilHashObjectArgsValidator().validate(Path("a.txt"), path=Path("p"), no_filters=True)
111
+ Traceback (most recent call last):
112
+ gitbolt.exceptions.GitExitingException: ValueError: path and no_filters are not allowed together
113
+
114
+ >>> UtilHashObjectArgsValidator().validate(path=Path("p"), stdin_paths=[Path("a.txt")])
115
+ Traceback (most recent call last):
116
+ gitbolt.exceptions.GitExitingException: ValueError: path and stdin_paths are not allowed together
117
+
118
+ >>> UtilHashObjectArgsValidator().validate("a.txt") # type: ignore[arg-type]
119
+ Traceback (most recent call last):
120
+ gitbolt.exceptions.GitExitingException: TypeError: 'file_path' must be a pathlib.Path
121
+
122
+ >>> UtilHashObjectArgsValidator().validate(Path("a.txt"), t="blobb") # type: ignore[arg-type]
123
+ Traceback (most recent call last):
124
+ gitbolt.exceptions.GitExitingException: ValueError: Unexpected t value. Choose from 'commit', 'tree', 'blob' and 'tag'.
125
+ """
126
+ self.mandate_required_arguments(
127
+ file_path,
128
+ *file_paths,
129
+ stdin=stdin,
130
+ stdin_paths=stdin_paths,
131
+ )
132
+ self.validate_exclusive_args(
133
+ file_path,
134
+ *file_paths,
135
+ path=path,
136
+ no_filters=no_filters,
137
+ stdin=stdin,
138
+ stdin_paths=stdin_paths,
139
+ )
140
+ self.validate_types(
141
+ file_path,
142
+ *file_paths,
143
+ t=t,
144
+ path=path,
145
+ no_filters=no_filters,
146
+ literally=literally,
147
+ stdin=stdin,
148
+ stdin_paths=stdin_paths,
149
+ w=w,
150
+ )
151
+
152
+ def mandate_required_arguments(
153
+ self,
154
+ file_path: Path | None,
155
+ *file_paths: Path,
156
+ stdin: bytes | None,
157
+ stdin_paths: list[Path] | None,
158
+ ) -> None:
159
+ """
160
+ Either a file path or stdin must be provided. ``stdin_paths`` counts as stdin.
161
+
162
+ >>> UtilHashObjectArgsValidator().mandate_required_arguments(Path("a.txt"), stdin=None, stdin_paths=None)
163
+ >>> UtilHashObjectArgsValidator().mandate_required_arguments(None, stdin=b"x", stdin_paths=None)
164
+ >>> UtilHashObjectArgsValidator().mandate_required_arguments(None, stdin=None, stdin_paths=[Path("a.txt")])
165
+
166
+ >>> UtilHashObjectArgsValidator().mandate_required_arguments(None, stdin=None, stdin_paths=None)
167
+ Traceback (most recent call last):
168
+ gitbolt.exceptions.GitExitingException: ValueError: Either file_path or stdin is required
169
+ """
170
+ has_file_path = has_atleast_one_arg(file_path, *file_paths, enforce_type=False)
171
+ has_stdin = stdin is not None or stdin_paths is not None
172
+ if not has_file_path and not has_stdin:
173
+ errmsg = errmsg_creator.at_least_one_required("file_path", "stdin")
174
+ raise GitExitingException(
175
+ errmsg, exit_code=ERR_INVALID_USAGE
176
+ ) from ValueError(errmsg)
177
+
178
+ def validate_exclusive_args(
179
+ self,
180
+ file_path: Path | None,
181
+ *file_paths: Path,
182
+ path: Path | None,
183
+ no_filters: bool,
184
+ stdin: bytes | None,
185
+ stdin_paths: list[Path] | None,
186
+ ) -> None:
187
+ """
188
+ Check that exclusive args are not provided together.
189
+
190
+ >>> UtilHashObjectArgsValidator().validate_exclusive_args(
191
+ ... Path("a.txt"), path=None, no_filters=False, stdin=None, stdin_paths=None
192
+ ... )
193
+ >>> UtilHashObjectArgsValidator().validate_exclusive_args(
194
+ ... Path("a.txt"), stdin_paths=[Path("b.txt")], path=None, no_filters=False, stdin=None
195
+ ... )
196
+ Traceback (most recent call last):
197
+ gitbolt.exceptions.GitExitingException: ValueError: file_path and stdin_paths are not allowed together
198
+ """
199
+ has_files = has_atleast_one_arg(file_path, *file_paths, enforce_type=False)
200
+ if has_files and stdin_paths is not None:
201
+ errmsg = errmsg_creator.not_allowed_together("file_path", "stdin_paths")
202
+ raise GitExitingException(
203
+ errmsg, exit_code=ERR_INVALID_USAGE
204
+ ) from ValueError(errmsg)
205
+ if stdin is not None and stdin_paths is not None:
206
+ errmsg = errmsg_creator.not_allowed_together("stdin", "stdin_paths")
207
+ raise GitExitingException(
208
+ errmsg, exit_code=ERR_INVALID_USAGE
209
+ ) from ValueError(errmsg)
210
+ if path is not None and no_filters:
211
+ errmsg = errmsg_creator.not_allowed_together("path", "no_filters")
212
+ raise GitExitingException(
213
+ errmsg, exit_code=ERR_INVALID_USAGE
214
+ ) from ValueError(errmsg)
215
+ if path is not None and stdin_paths is not None:
216
+ errmsg = errmsg_creator.not_allowed_together("path", "stdin_paths")
217
+ raise GitExitingException(
218
+ errmsg, exit_code=ERR_INVALID_USAGE
219
+ ) from ValueError(errmsg)
220
+
221
+ def validate_types(
222
+ self,
223
+ file_path: Path | None,
224
+ *file_paths: Path,
225
+ t: Literal["commit", "tree", "blob", "tag"],
226
+ path: Path | None,
227
+ no_filters: bool,
228
+ literally: bool,
229
+ stdin: bytes | None,
230
+ stdin_paths: list[Path] | None,
231
+ w: bool,
232
+ ) -> None:
233
+ if file_path is not None:
234
+ self._require_path(file_path, "file_path")
235
+ for extra_path in file_paths:
236
+ self._require_path(extra_path, "file_path")
237
+ if t not in _HASH_OBJECT_TYPES:
238
+ errmsg = errmsg_creator.errmsg_for_choices(
239
+ emphasis="t", choices=list(_HASH_OBJECT_TYPES)
240
+ )
241
+ raise GitExitingException(
242
+ errmsg, exit_code=ERR_INVALID_USAGE
243
+ ) from ValueError(errmsg)
244
+ if path is not None:
245
+ self._require_path(path, "path")
246
+ require_type(no_filters, "no_filters", bool, GitExitingException)
247
+ require_type(literally, "literally", bool, GitExitingException)
248
+ require_type(w, "w", bool, GitExitingException)
249
+ if stdin is not None:
250
+ if not isinstance(stdin, (bytes, bytearray)):
251
+ errmsg = "'stdin' must be bytes"
252
+ raise GitExitingException(
253
+ errmsg, exit_code=ERR_DATA_FORMAT_ERR
254
+ ) from TypeError(errmsg)
255
+ if stdin_paths is not None:
256
+ require_iterable(stdin_paths, "stdin_paths", Path, list, GitExitingException)
257
+
258
+ def _require_path(self, value: Path, name: str) -> None:
259
+ if not isinstance(value, Path):
260
+ errmsg = f"'{name}' must be a pathlib.Path"
261
+ raise GitExitingException(
262
+ errmsg, exit_code=ERR_DATA_FORMAT_ERR
263
+ ) from TypeError(errmsg)
@@ -11,6 +11,8 @@ from gitbolt.subprocess.base import GitSubcmdCommand as GitSubcmdCommand
11
11
  from gitbolt.subprocess.base import AddCommand as AddCommand
12
12
  from gitbolt.subprocess.base import LsTreeCommand as LsTreeCommand
13
13
  from gitbolt.subprocess.base import VersionCommand as VersionCommand
14
+ from gitbolt.subprocess.base import HashObjectCommand as HashObjectCommand
15
+ from gitbolt.subprocess.base import WritingHashObjectCommand as WritingHashObjectCommand
14
16
  from gitbolt.subprocess.base import UncheckedSubcmd as UncheckedSubcmd
15
17
  from gitbolt.subprocess.base import GitSession as GitSession
16
18
  # endregion