gitbolt 0.0.0.dev21__tar.gz → 0.0.0.dev22__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.dev21 → gitbolt-0.0.0.dev22}/PKG-INFO +1 -1
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/pyproject.toml +1 -1
- gitbolt-0.0.0.dev22/src/gitbolt/base.py +680 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/base.py +245 -1
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/impl/simple.py +156 -6
- gitbolt-0.0.0.dev22/src/gitbolt/subprocess/worktree.py +273 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt.egg-info/PKG-INFO +1 -1
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt.egg-info/SOURCES.txt +1 -0
- gitbolt-0.0.0.dev21/src/gitbolt/base.py +0 -355
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/LICENSE +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/README.md +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/setup.cfg +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/__init__.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/_internal_init.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/add.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/constants.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/exceptions.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/ls_tree.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/models.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/py.typed +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/pytest_plugin.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/__init__.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/_internal_init.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/add.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/constants.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/exceptions.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/impl/__init__.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/ls_tree.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/runner/__init__.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/runner/base.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/runner/simple.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/utils/__init__.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/utils/cmd.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/utils/models.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/subprocess/utils/session.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt/utils.py +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt.egg-info/dependency_links.txt +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt.egg-info/entry_points.txt +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/src/gitbolt.egg-info/requires.txt +0 -0
- {gitbolt-0.0.0.dev21 → gitbolt-0.0.0.dev22}/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.
|
|
3
|
+
Version: 0.0.0.dev22
|
|
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>
|
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# coding=utf-8
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
interfaces related to processors specific to git commands.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from abc import abstractmethod
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Protocol, override, Unpack, Self, overload, Literal
|
|
14
|
+
|
|
15
|
+
from vt.utils.commons.commons.core_py import UNSET, Unset
|
|
16
|
+
from vt.utils.commons.commons.op import RootDirOp
|
|
17
|
+
from vt.utils.errors.error_specs import ERR_DATA_FORMAT_ERR
|
|
18
|
+
|
|
19
|
+
from gitbolt.exceptions import GitExitingException
|
|
20
|
+
from gitbolt.models import GitOpts, GitAddOpts, GitLsTreeOpts, GitEnvVars
|
|
21
|
+
from gitbolt.ls_tree import LsTreeArgsValidator, UtilLsTreeArgsValidator
|
|
22
|
+
from gitbolt.add import AddArgsValidator, UtilAddArgsValidator
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class HasGitUnderneath[G: "Git"](Protocol):
|
|
26
|
+
"""
|
|
27
|
+
Stores a reference to main git instance.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
@abstractmethod
|
|
32
|
+
def git(self) -> G:
|
|
33
|
+
"""
|
|
34
|
+
:return: stored underlying git instance reference.
|
|
35
|
+
"""
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class CanOverrideGitOpts(Protocol):
|
|
40
|
+
"""
|
|
41
|
+
Can override main git command options.
|
|
42
|
+
|
|
43
|
+
For example, in ``git --no-pager log -1 master`` git command, ``--no-pager`` is the main command arg.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
@abstractmethod
|
|
47
|
+
def git_opts_override(self, **overrides: Unpack[GitOpts]) -> Self:
|
|
48
|
+
"""
|
|
49
|
+
Temporarily override options to the main git command before current subcommand runs.
|
|
50
|
+
|
|
51
|
+
Get a new ``Git`` object with the git main command options overridden.
|
|
52
|
+
|
|
53
|
+
All the parameters mirror options described in the `git documentation <https://git-scm.com/docs/git>`_.
|
|
54
|
+
|
|
55
|
+
For example, in ``git --no-pager log -1 master`` git command, ``--no-pager`` is the main command arg.
|
|
56
|
+
|
|
57
|
+
:return: instance with overridden git main command args.
|
|
58
|
+
"""
|
|
59
|
+
...
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class CanOverrideGitEnvs(Protocol):
|
|
63
|
+
"""
|
|
64
|
+
Can override main git command environment variables.
|
|
65
|
+
|
|
66
|
+
For example, in ``GIT_COMMITTER_NAME=vt git --no-pager commit -m "a message"`` git command,
|
|
67
|
+
``GIT_COMMITTER_NAME=ss``, particularly ``GIT_COMMITTER_NAME`` is the git environment variable.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
@abstractmethod
|
|
71
|
+
def git_envs_override(self, **overrides: Unpack[GitEnvVars]) -> Self:
|
|
72
|
+
"""
|
|
73
|
+
Temporarily override environment variables supplied to the git command before current subcommand runs.
|
|
74
|
+
|
|
75
|
+
Get a new ``Git`` object with the git environment variables overridden.
|
|
76
|
+
|
|
77
|
+
All the environment variables mirror envs described in the `git documentation <https://git-scm.com/docs/git#_environment_variables>`_.
|
|
78
|
+
|
|
79
|
+
For example, in ``GIT_COMMITTER_NAME=vt git --no-pager commit -m "a message"`` git command,
|
|
80
|
+
``GIT_COMMITTER_NAME=vt``, particularly ``GIT_COMMITTER_NAME`` is the git environment variable.
|
|
81
|
+
|
|
82
|
+
:return: instance with overridden git environment variables.
|
|
83
|
+
"""
|
|
84
|
+
...
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class GitSubCommand(CanOverrideGitOpts, CanOverrideGitEnvs, Protocol):
|
|
88
|
+
"""
|
|
89
|
+
Interface for git subcommands, such as:
|
|
90
|
+
|
|
91
|
+
* ``add``
|
|
92
|
+
* ``commit``
|
|
93
|
+
* ``pull``
|
|
94
|
+
* ...
|
|
95
|
+
etc.
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
@abstractmethod
|
|
99
|
+
def clone(self) -> Self:
|
|
100
|
+
"""
|
|
101
|
+
:return: a clone of the underlying subcommand.
|
|
102
|
+
"""
|
|
103
|
+
...
|
|
104
|
+
|
|
105
|
+
@abstractmethod
|
|
106
|
+
def _subcmd_from_git(self, git: "Git") -> Self:
|
|
107
|
+
"""
|
|
108
|
+
Protected. Intended for inheritance only.
|
|
109
|
+
|
|
110
|
+
:return: specific implementation of subcommand from ``git``.
|
|
111
|
+
"""
|
|
112
|
+
...
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class LsTree(GitSubCommand, RootDirOp, Protocol):
|
|
116
|
+
"""
|
|
117
|
+
Interface for ``git ls-tree`` command.
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
@abstractmethod
|
|
121
|
+
def ls_tree(self, tree_ish: str, **ls_tree_opts: Unpack[GitLsTreeOpts]) -> str:
|
|
122
|
+
"""
|
|
123
|
+
All the parameters are mirrors of the parameters of ``git ls-tree`` CLI command
|
|
124
|
+
from `git ls-tree documentation <https://git-scm.com/docs/git-ls-tree>`_.
|
|
125
|
+
|
|
126
|
+
:param tree_ish: A tree-ish identifier (commit SHA, branch name, etc.).
|
|
127
|
+
:param ls_tree_opts: Keyword arguments mapping to supported options for ``git ls-tree``.
|
|
128
|
+
:return: ``ls-tree`` output.
|
|
129
|
+
"""
|
|
130
|
+
...
|
|
131
|
+
|
|
132
|
+
@override
|
|
133
|
+
def _subcmd_from_git(self, git: "Git") -> "LsTree":
|
|
134
|
+
return git.ls_tree_subcmd
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def args_validator(self) -> LsTreeArgsValidator:
|
|
138
|
+
"""
|
|
139
|
+
The argument validator for ``git ls-tree`` subcommand.
|
|
140
|
+
|
|
141
|
+
:return: a validator for ls_tree subcommand arguments.
|
|
142
|
+
"""
|
|
143
|
+
return UtilLsTreeArgsValidator()
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class Add(GitSubCommand, RootDirOp, Protocol):
|
|
147
|
+
"""
|
|
148
|
+
Interface for ``git add`` command.
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
# TODO: `pathspec: str` -> `pathspec_or_path: str | Path`.
|
|
152
|
+
# This will make a convenience method for python use.
|
|
153
|
+
@overload
|
|
154
|
+
@abstractmethod
|
|
155
|
+
def add(
|
|
156
|
+
self, pathspec: str, *pathspecs: str, **add_opts: Unpack[GitAddOpts]
|
|
157
|
+
) -> str:
|
|
158
|
+
"""
|
|
159
|
+
Add files specified by a list of pathspec strings.
|
|
160
|
+
`pathspec_from_file` and `pathspec_file_null` are disallowed here.
|
|
161
|
+
|
|
162
|
+
Mirrors the parameters of ``git add`` CLI command
|
|
163
|
+
from `git add documentation <https://git-scm.com/docs/git-add>`_.
|
|
164
|
+
|
|
165
|
+
:return: output of ``git add``.
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
@overload
|
|
169
|
+
@abstractmethod
|
|
170
|
+
def add(
|
|
171
|
+
self,
|
|
172
|
+
*,
|
|
173
|
+
pathspec_from_file: Path,
|
|
174
|
+
pathspec_file_nul: bool = False,
|
|
175
|
+
**add_opts: Unpack[GitAddOpts],
|
|
176
|
+
) -> str:
|
|
177
|
+
"""
|
|
178
|
+
Add files listed in a file (`pathspec_from_file`) to the index.
|
|
179
|
+
`pathspec_file_null` indicates if the file is NUL terminated.
|
|
180
|
+
No explicit pathspec list is allowed in this overload.
|
|
181
|
+
|
|
182
|
+
Mirrors the parameters of ``git add`` CLI command
|
|
183
|
+
from `git add documentation <https://git-scm.com/docs/git-add>`_.
|
|
184
|
+
|
|
185
|
+
:return: output of ``git add``.
|
|
186
|
+
"""
|
|
187
|
+
|
|
188
|
+
@overload
|
|
189
|
+
@abstractmethod
|
|
190
|
+
def add(
|
|
191
|
+
self,
|
|
192
|
+
*,
|
|
193
|
+
pathspec_from_file: Literal["-"],
|
|
194
|
+
pathspec_stdin: str,
|
|
195
|
+
pathspec_file_nul: bool = False,
|
|
196
|
+
**add_opts: Unpack[GitAddOpts],
|
|
197
|
+
) -> str:
|
|
198
|
+
"""
|
|
199
|
+
Add files listed from stdin (when `pathspec_from_file` is '-').
|
|
200
|
+
The `pathspec_stdin` argument is the string content piped to stdin.
|
|
201
|
+
|
|
202
|
+
Mirrors the parameters of ``git add`` CLI command
|
|
203
|
+
from `git add documentation <https://git-scm.com/docs/git-add>`_.
|
|
204
|
+
|
|
205
|
+
:return: output of ``git add``.
|
|
206
|
+
"""
|
|
207
|
+
|
|
208
|
+
@property
|
|
209
|
+
def args_validator(self) -> AddArgsValidator:
|
|
210
|
+
"""
|
|
211
|
+
The argument validator for ``git add`` subcommand.
|
|
212
|
+
|
|
213
|
+
:return: a validator for add subcommand arguments.
|
|
214
|
+
"""
|
|
215
|
+
return UtilAddArgsValidator()
|
|
216
|
+
|
|
217
|
+
@override
|
|
218
|
+
def _subcmd_from_git(self, git: "Git") -> "Add":
|
|
219
|
+
return git.add_subcmd
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
class Version(GitSubCommand, Protocol):
|
|
223
|
+
"""
|
|
224
|
+
Interface for ``git version`` command.
|
|
225
|
+
"""
|
|
226
|
+
|
|
227
|
+
class VersionInfo:
|
|
228
|
+
@abstractmethod
|
|
229
|
+
def version(self) -> str: ...
|
|
230
|
+
|
|
231
|
+
@abstractmethod
|
|
232
|
+
def semver(self) -> tuple: ...
|
|
233
|
+
|
|
234
|
+
class VersionWithBuildInfo(VersionInfo):
|
|
235
|
+
@abstractmethod
|
|
236
|
+
def build_options(self) -> dict[str, str]: ...
|
|
237
|
+
|
|
238
|
+
@overload
|
|
239
|
+
@abstractmethod
|
|
240
|
+
def version(self) -> VersionInfo: ...
|
|
241
|
+
|
|
242
|
+
@overload
|
|
243
|
+
@abstractmethod
|
|
244
|
+
def version(self, build_options: Literal[True]) -> VersionWithBuildInfo: ...
|
|
245
|
+
|
|
246
|
+
@abstractmethod
|
|
247
|
+
def version(
|
|
248
|
+
self, build_options: Literal[True, False] = False
|
|
249
|
+
) -> VersionInfo | VersionWithBuildInfo:
|
|
250
|
+
"""
|
|
251
|
+
All the parameters are mirrors of the parameters of ``git version`` CLI command
|
|
252
|
+
from `git version documentation <https://git-scm.com/docs/git-version>`_.
|
|
253
|
+
|
|
254
|
+
:return: ``version`` output.
|
|
255
|
+
"""
|
|
256
|
+
...
|
|
257
|
+
|
|
258
|
+
@staticmethod
|
|
259
|
+
def _require_valid_args(build_options: bool = False) -> None:
|
|
260
|
+
"""
|
|
261
|
+
Require that arguments sent to the version command is valid.
|
|
262
|
+
|
|
263
|
+
Examples:
|
|
264
|
+
|
|
265
|
+
Correct:
|
|
266
|
+
|
|
267
|
+
>>> Version._require_valid_args()
|
|
268
|
+
|
|
269
|
+
Error:
|
|
270
|
+
|
|
271
|
+
>>> Version._require_valid_args(1) # type: ignore[arg-type] # required bool, supplied int
|
|
272
|
+
Traceback (most recent call last):
|
|
273
|
+
gitbolt.exceptions.GitExitingException: TypeError: build_options should be bool.
|
|
274
|
+
|
|
275
|
+
:param build_options: argument to be validated.
|
|
276
|
+
:raise GitExitingException: if supplied ``build_options`` is invalid.
|
|
277
|
+
"""
|
|
278
|
+
if not isinstance(build_options, bool):
|
|
279
|
+
errmsg = "build_options should be bool."
|
|
280
|
+
raise GitExitingException(
|
|
281
|
+
errmsg, exit_code=ERR_DATA_FORMAT_ERR
|
|
282
|
+
) from TypeError(errmsg)
|
|
283
|
+
|
|
284
|
+
@override
|
|
285
|
+
def _subcmd_from_git(self, git: "Git") -> "Version":
|
|
286
|
+
return git.version_subcmd
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class Worktree(GitSubCommand, RootDirOp, Protocol):
|
|
290
|
+
"""
|
|
291
|
+
Interface for ``git worktree`` subcommand.
|
|
292
|
+
"""
|
|
293
|
+
|
|
294
|
+
class WorktreeSubcmd(RootDirOp, Protocol):
|
|
295
|
+
"""
|
|
296
|
+
Interface for the worktree subcommands.
|
|
297
|
+
"""
|
|
298
|
+
|
|
299
|
+
@property
|
|
300
|
+
@abstractmethod
|
|
301
|
+
def underlying_worktree(self) -> Worktree:
|
|
302
|
+
"""
|
|
303
|
+
:return: underlying worktree for this subcommand.
|
|
304
|
+
"""
|
|
305
|
+
...
|
|
306
|
+
|
|
307
|
+
# region worktree list subcommands
|
|
308
|
+
class List(WorktreeSubcmd, Protocol):
|
|
309
|
+
"""
|
|
310
|
+
Interface for ``git worktree list`` subcommand.
|
|
311
|
+
"""
|
|
312
|
+
|
|
313
|
+
@abstractmethod
|
|
314
|
+
@overload
|
|
315
|
+
def list(self, *, verbose: bool = False) -> str:
|
|
316
|
+
...
|
|
317
|
+
|
|
318
|
+
@abstractmethod
|
|
319
|
+
@overload
|
|
320
|
+
def list(self, *, porcelain: Literal[False]) -> str:
|
|
321
|
+
...
|
|
322
|
+
|
|
323
|
+
@abstractmethod
|
|
324
|
+
@overload
|
|
325
|
+
def list(self, *, porcelain: Literal[True], z: Literal[True] | Unset = UNSET) -> str:
|
|
326
|
+
...
|
|
327
|
+
|
|
328
|
+
@abstractmethod
|
|
329
|
+
def list(self, *, verbose: bool | Unset = UNSET, porcelain: Literal[True, False] | Unset = UNSET,
|
|
330
|
+
z: Literal[True] | Unset = UNSET) -> str:
|
|
331
|
+
"""
|
|
332
|
+
List all the worktrees.
|
|
333
|
+
|
|
334
|
+
``git worktree list`` documentation: https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-list
|
|
335
|
+
|
|
336
|
+
:param verbose: https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---verbose
|
|
337
|
+
:param porcelain: https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---porcelain
|
|
338
|
+
:param z: This option can only be used if porcelain is enabled. See
|
|
339
|
+
https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt--z for more details.
|
|
340
|
+
:returns: stdout of the command run.
|
|
341
|
+
"""
|
|
342
|
+
...
|
|
343
|
+
|
|
344
|
+
@property
|
|
345
|
+
@abstractmethod
|
|
346
|
+
def list_subcmd(self) -> Worktree.List:
|
|
347
|
+
"""
|
|
348
|
+
:returns: ``git worktree list`` subcommand.
|
|
349
|
+
"""
|
|
350
|
+
...
|
|
351
|
+
|
|
352
|
+
# endregion
|
|
353
|
+
|
|
354
|
+
# region worktree lock subcommands
|
|
355
|
+
class Lock(WorktreeSubcmd, Protocol):
|
|
356
|
+
"""
|
|
357
|
+
Interface for ``git worktree lock`` subcommand.
|
|
358
|
+
"""
|
|
359
|
+
|
|
360
|
+
@abstractmethod
|
|
361
|
+
def lock(self, worktree: Path, reason: str | Literal[False] | Unset = UNSET) -> str:
|
|
362
|
+
"""
|
|
363
|
+
Lock a worktree to prevent administrative files form being pruned automatically.
|
|
364
|
+
|
|
365
|
+
`git worktree lock documentation
|
|
366
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-lock>`_.
|
|
367
|
+
|
|
368
|
+
:param worktree: Path to the worktree that is to be locked.
|
|
369
|
+
:param reason: `a reason for why a worktree is locked
|
|
370
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-lock>`_.
|
|
371
|
+
:return: git worktree lock output.
|
|
372
|
+
"""
|
|
373
|
+
...
|
|
374
|
+
|
|
375
|
+
@property
|
|
376
|
+
@abstractmethod
|
|
377
|
+
def lock_subcmd(self) -> Worktree.Lock:
|
|
378
|
+
"""
|
|
379
|
+
:returns: ``git worktree lock`` subcommand.
|
|
380
|
+
"""
|
|
381
|
+
...
|
|
382
|
+
|
|
383
|
+
# endregion
|
|
384
|
+
|
|
385
|
+
# region worktree unlock subcommands
|
|
386
|
+
class UnLock(WorktreeSubcmd, Protocol):
|
|
387
|
+
"""
|
|
388
|
+
Interface for ``git worktree unlock`` subcommand.
|
|
389
|
+
"""
|
|
390
|
+
|
|
391
|
+
@abstractmethod
|
|
392
|
+
def unlock(self, worktree: Path) -> str:
|
|
393
|
+
"""
|
|
394
|
+
Unlock a locked worktree for pruning or deletion.
|
|
395
|
+
|
|
396
|
+
`git worktree unlock documentation
|
|
397
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-unlock>`_.
|
|
398
|
+
|
|
399
|
+
:param worktree: Path to the worktree that is to be unlocked.
|
|
400
|
+
:return: git worktree unlock output.
|
|
401
|
+
"""
|
|
402
|
+
...
|
|
403
|
+
|
|
404
|
+
@property
|
|
405
|
+
@abstractmethod
|
|
406
|
+
def unlock_subcmd(self) -> Worktree.UnLock:
|
|
407
|
+
"""
|
|
408
|
+
:returns: ``git worktree unlock`` subcommand.
|
|
409
|
+
"""
|
|
410
|
+
...
|
|
411
|
+
|
|
412
|
+
# endregion
|
|
413
|
+
|
|
414
|
+
# region worktree move subcommands
|
|
415
|
+
class Move(WorktreeSubcmd, Protocol):
|
|
416
|
+
"""
|
|
417
|
+
Interface for ``git worktree move`` subcommand.
|
|
418
|
+
"""
|
|
419
|
+
|
|
420
|
+
@abstractmethod
|
|
421
|
+
def move(self, worktree: Path, new_path: Path, *, force: bool | Unset = UNSET, reforce: bool | Unset = UNSET,
|
|
422
|
+
relative_paths: bool | Unset = UNSET) -> str:
|
|
423
|
+
"""
|
|
424
|
+
Move the worktree. Documentation: https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-move
|
|
425
|
+
|
|
426
|
+
Also, info on ``git worktree move -h``.
|
|
427
|
+
|
|
428
|
+
:param worktree: Path to the worktree that is to be moved.
|
|
429
|
+
:param new_path: Path where the worktree is to be moved.
|
|
430
|
+
:param force: `force move a worktree even when it is locked <https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---force>`_.
|
|
431
|
+
:param reforce: multiple force arguments for moving a locked worktree.
|
|
432
|
+
:param relative_paths: `use relative paths for worktree <https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---no-relative-paths>`_.
|
|
433
|
+
:return: output of ``git worktree move``.
|
|
434
|
+
"""
|
|
435
|
+
|
|
436
|
+
@property
|
|
437
|
+
@abstractmethod
|
|
438
|
+
def move_subcmd(self) -> Worktree.Move:
|
|
439
|
+
"""
|
|
440
|
+
:returns: ``git worktree move`` subcommand.
|
|
441
|
+
"""
|
|
442
|
+
...
|
|
443
|
+
|
|
444
|
+
# endregion
|
|
445
|
+
|
|
446
|
+
# region worktree prune subcommands
|
|
447
|
+
class Prune(WorktreeSubcmd, Protocol):
|
|
448
|
+
"""
|
|
449
|
+
Interface for ``git worktree prune`` subcommand.
|
|
450
|
+
|
|
451
|
+
Documentation: https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-prune
|
|
452
|
+
"""
|
|
453
|
+
|
|
454
|
+
@abstractmethod
|
|
455
|
+
def prune(self, *, dry_run: bool | Unset = UNSET, verbose: bool | Unset = UNSET,
|
|
456
|
+
expire: Literal[False] | int | datetime | Unset = UNSET) -> str:
|
|
457
|
+
"""
|
|
458
|
+
Prune worktrees satisfying pruning conditions.
|
|
459
|
+
|
|
460
|
+
:param dry_run: `Just dry run the operation and do not actually prune anything.
|
|
461
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---dry-run>`_.
|
|
462
|
+
:param verbose: `be verbose while pruning
|
|
463
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---verbose>`_.
|
|
464
|
+
:param expire: `prune worktrees older than this expiration time
|
|
465
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---expiretime>`_.
|
|
466
|
+
:returns: prune output in string format.
|
|
467
|
+
"""
|
|
468
|
+
...
|
|
469
|
+
|
|
470
|
+
@property
|
|
471
|
+
@abstractmethod
|
|
472
|
+
def prune_subcmd(self) -> Worktree.Prune:
|
|
473
|
+
"""
|
|
474
|
+
:returns: ``git worktree prune`` subcommand.
|
|
475
|
+
"""
|
|
476
|
+
...
|
|
477
|
+
# endregion
|
|
478
|
+
|
|
479
|
+
# region worktree remove subcommands
|
|
480
|
+
class Remove(WorktreeSubcmd, Protocol):
|
|
481
|
+
"""
|
|
482
|
+
Interface for ``git worktree remove`` subcommand.
|
|
483
|
+
|
|
484
|
+
Documentation: https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-remove
|
|
485
|
+
"""
|
|
486
|
+
|
|
487
|
+
@abstractmethod
|
|
488
|
+
def remove(self, worktree: Path, *, force: bool | Unset = UNSET, reforce: bool | Unset = UNSET) -> str:
|
|
489
|
+
"""
|
|
490
|
+
Remove worktree.
|
|
491
|
+
|
|
492
|
+
:param worktree: path of the worktree to remove.
|
|
493
|
+
:param force: `force remove this worktree
|
|
494
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---force>`_.
|
|
495
|
+
:param reforce: unclean but locked worktree needs multiple force arguments for worktree removal.
|
|
496
|
+
:returns: remove output in string format.
|
|
497
|
+
"""
|
|
498
|
+
...
|
|
499
|
+
|
|
500
|
+
@property
|
|
501
|
+
@abstractmethod
|
|
502
|
+
def remove_subcmd(self) -> Worktree.Remove:
|
|
503
|
+
"""
|
|
504
|
+
:returns: ``git worktree remove`` subcommand.
|
|
505
|
+
"""
|
|
506
|
+
...
|
|
507
|
+
# endregion
|
|
508
|
+
|
|
509
|
+
# region worktree repair subcommands
|
|
510
|
+
class Repair(WorktreeSubcmd, Protocol):
|
|
511
|
+
"""
|
|
512
|
+
Interface for ``git worktree repair`` subcommand.
|
|
513
|
+
|
|
514
|
+
Documentation: https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-repair
|
|
515
|
+
"""
|
|
516
|
+
|
|
517
|
+
@abstractmethod
|
|
518
|
+
def repair(self, *worktrees: Path, relative_paths: Unset | bool = UNSET) -> str:
|
|
519
|
+
"""
|
|
520
|
+
Repair worktree(s).
|
|
521
|
+
|
|
522
|
+
:param worktrees: paths of the worktree to repair.
|
|
523
|
+
:param relative_paths: `use relative paths for worktree
|
|
524
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---relative-paths>`_.
|
|
525
|
+
:returns: remove output in string format.
|
|
526
|
+
"""
|
|
527
|
+
...
|
|
528
|
+
|
|
529
|
+
@property
|
|
530
|
+
@abstractmethod
|
|
531
|
+
def repair_subcmd(self) -> Worktree.Repair:
|
|
532
|
+
"""
|
|
533
|
+
:returns: ``git worktree repair`` subcommand.
|
|
534
|
+
"""
|
|
535
|
+
...
|
|
536
|
+
# endregion
|
|
537
|
+
|
|
538
|
+
# region worktree add subcommand
|
|
539
|
+
class Add(WorktreeSubcmd, Protocol):
|
|
540
|
+
"""
|
|
541
|
+
Interface for ``git worktree add`` subcommand.
|
|
542
|
+
|
|
543
|
+
Documentation: https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-add
|
|
544
|
+
"""
|
|
545
|
+
|
|
546
|
+
def add(self, worktree: Path, commit_ish: str | None = None, *, force: bool | Unset = UNSET,
|
|
547
|
+
reforce: bool | Unset = UNSET, new_branch: str | Unset = UNSET, new_branch_force: str | Unset = UNSET,
|
|
548
|
+
orphan: Literal[True] | Unset = UNSET, detach: Literal[True] | Unset = UNSET,
|
|
549
|
+
checkout: bool | Unset = UNSET, lock: bool | Unset = UNSET,
|
|
550
|
+
reason: str | Literal[False] | Unset = UNSET, quiet: bool | Unset = UNSET,
|
|
551
|
+
track: bool | Unset = UNSET, guess_remote: bool | Unset = UNSET,
|
|
552
|
+
relative_paths: bool | Unset = UNSET) -> str:
|
|
553
|
+
"""
|
|
554
|
+
Add worktree.
|
|
555
|
+
|
|
556
|
+
:param worktree: path of the worktree to add.
|
|
557
|
+
:param commit_ish: `add a worktree by checking out commit-ish
|
|
558
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-addpathcommit-ish>`_.
|
|
559
|
+
:param force: `force remove this worktree
|
|
560
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---force>`_.
|
|
561
|
+
:param reforce: add a missing but locked worktree path.
|
|
562
|
+
:param new_branch: `add a new branch for worktree.
|
|
563
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-addpathcommit-ish>`_.
|
|
564
|
+
:param new_branch_force: `add a new branch for worktree. Creates a branch at commit_ish even if it
|
|
565
|
+
exists already
|
|
566
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-addpathcommit-ish>`_.
|
|
567
|
+
:param orphan: `orphan unborn branch worktree
|
|
568
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-addpathcommit-ish>`_.
|
|
569
|
+
:param detach: `create a detached worktree
|
|
570
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---detach>`_.
|
|
571
|
+
:param checkout: `checkout the branch in worktree
|
|
572
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---checkout>`_.
|
|
573
|
+
:param lock: `keep the worktree locked after creation
|
|
574
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---lock>`_.
|
|
575
|
+
:param reason: `explanation of why a worktree is locked
|
|
576
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---reasonstring>`_.
|
|
577
|
+
:param quiet: `suppress add feedback messages
|
|
578
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---quiet>`_.
|
|
579
|
+
:param track: `track certain upstream branch
|
|
580
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---track>`_.
|
|
581
|
+
:param guess_remote: `check if a branch already exists on remote that matches this one
|
|
582
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---guess-remote>`_.
|
|
583
|
+
:param relative_paths: `link worktrees using relative paths instead of absolute path (the default)
|
|
584
|
+
<https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---relative-paths>`_.
|
|
585
|
+
:returns: add output in string format.
|
|
586
|
+
"""
|
|
587
|
+
...
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
@property
|
|
591
|
+
@abstractmethod
|
|
592
|
+
def add_subcmd(self) -> Worktree.Add:
|
|
593
|
+
"""
|
|
594
|
+
:returns: ``git worktree add`` subcommand.
|
|
595
|
+
"""
|
|
596
|
+
...
|
|
597
|
+
# endregion
|
|
598
|
+
|
|
599
|
+
@override
|
|
600
|
+
def _subcmd_from_git(self, git: "Git") -> "Worktree":
|
|
601
|
+
return git.worktree_subcmd
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
class Git(CanOverrideGitOpts, CanOverrideGitEnvs, Protocol):
|
|
605
|
+
"""
|
|
606
|
+
Class designed analogous to documentation provided on `git documentation <https://git-scm.com/docs/git>`_.
|
|
607
|
+
"""
|
|
608
|
+
|
|
609
|
+
def version(self) -> Version.VersionInfo:
|
|
610
|
+
"""
|
|
611
|
+
:return: current git version.
|
|
612
|
+
"""
|
|
613
|
+
return self.version_subcmd.version()
|
|
614
|
+
|
|
615
|
+
@abstractmethod
|
|
616
|
+
def exec_path(self) -> Path:
|
|
617
|
+
"""
|
|
618
|
+
:return: Path to wherever your core Git programs are installed.
|
|
619
|
+
"""
|
|
620
|
+
...
|
|
621
|
+
|
|
622
|
+
@abstractmethod
|
|
623
|
+
def html_path(self) -> Path:
|
|
624
|
+
"""
|
|
625
|
+
:return: the path, without trailing slash, where Git’s HTML documentation is installed.
|
|
626
|
+
"""
|
|
627
|
+
...
|
|
628
|
+
|
|
629
|
+
@abstractmethod
|
|
630
|
+
def info_path(self) -> Path:
|
|
631
|
+
"""
|
|
632
|
+
:return: the path where the Info files documenting this version of Git are installed.
|
|
633
|
+
"""
|
|
634
|
+
...
|
|
635
|
+
|
|
636
|
+
@abstractmethod
|
|
637
|
+
def man_path(self) -> Path:
|
|
638
|
+
"""
|
|
639
|
+
:return: the man path (see man(1)) for the man pages for this version of Git.
|
|
640
|
+
"""
|
|
641
|
+
...
|
|
642
|
+
|
|
643
|
+
@property
|
|
644
|
+
@abstractmethod
|
|
645
|
+
def version_subcmd(self) -> Version:
|
|
646
|
+
"""
|
|
647
|
+
:return: ``git version`` subcommand.
|
|
648
|
+
"""
|
|
649
|
+
...
|
|
650
|
+
|
|
651
|
+
@property
|
|
652
|
+
@abstractmethod
|
|
653
|
+
def ls_tree_subcmd(self) -> LsTree:
|
|
654
|
+
"""
|
|
655
|
+
:return: ``git ls-tree`` subcommand.
|
|
656
|
+
"""
|
|
657
|
+
...
|
|
658
|
+
|
|
659
|
+
@property
|
|
660
|
+
@abstractmethod
|
|
661
|
+
def add_subcmd(self) -> Add:
|
|
662
|
+
"""
|
|
663
|
+
:return: ``git add`` subcommand.
|
|
664
|
+
"""
|
|
665
|
+
...
|
|
666
|
+
|
|
667
|
+
@property
|
|
668
|
+
@abstractmethod
|
|
669
|
+
def worktree_subcmd(self) -> Worktree:
|
|
670
|
+
"""
|
|
671
|
+
:return: ``git worktree`` subcommand.
|
|
672
|
+
"""
|
|
673
|
+
...
|
|
674
|
+
|
|
675
|
+
@abstractmethod
|
|
676
|
+
def clone(self) -> Self:
|
|
677
|
+
"""
|
|
678
|
+
:return: a clone of this class.
|
|
679
|
+
"""
|
|
680
|
+
...
|