GitPython 3.1.42__py3-none-any.whl → 3.1.43__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.
- {GitPython-3.1.42.dist-info → GitPython-3.1.43.dist-info}/METADATA +36 -29
- GitPython-3.1.43.dist-info/RECORD +44 -0
- {GitPython-3.1.42.dist-info → GitPython-3.1.43.dist-info}/WHEEL +1 -1
- git/__init__.py +203 -46
- git/cmd.py +541 -316
- git/compat.py +65 -30
- git/config.py +118 -77
- git/db.py +16 -16
- git/diff.py +176 -76
- git/exc.py +14 -8
- git/index/__init__.py +11 -2
- git/index/base.py +374 -308
- git/index/fun.py +87 -67
- git/index/typ.py +33 -25
- git/index/util.py +7 -13
- git/objects/__init__.py +19 -18
- git/objects/base.py +115 -48
- git/objects/blob.py +17 -6
- git/objects/commit.py +206 -136
- git/objects/fun.py +56 -44
- git/objects/submodule/__init__.py +4 -2
- git/objects/submodule/base.py +410 -225
- git/objects/submodule/root.py +99 -74
- git/objects/submodule/util.py +25 -24
- git/objects/tag.py +47 -16
- git/objects/tree.py +83 -62
- git/objects/util.py +149 -110
- git/refs/__init__.py +17 -8
- git/refs/head.py +61 -51
- git/refs/log.py +83 -52
- git/refs/reference.py +40 -30
- git/refs/remote.py +15 -16
- git/refs/symbolic.py +183 -126
- git/refs/tag.py +34 -20
- git/remote.py +235 -155
- git/repo/__init__.py +4 -2
- git/repo/base.py +370 -238
- git/repo/fun.py +122 -96
- git/types.py +198 -31
- git/util.py +250 -200
- GitPython-3.1.42.dist-info/RECORD +0 -44
- {GitPython-3.1.42.dist-info → GitPython-3.1.43.dist-info}/AUTHORS +0 -0
- {GitPython-3.1.42.dist-info → GitPython-3.1.43.dist-info}/LICENSE +0 -0
- {GitPython-3.1.42.dist-info → GitPython-3.1.43.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: GitPython
|
|
3
|
-
Version: 3.1.
|
|
3
|
+
Version: 3.1.43
|
|
4
4
|
Summary: GitPython is a Python library used to interact with Git repositories
|
|
5
5
|
Home-page: https://github.com/gitpython-developers/GitPython
|
|
6
6
|
Author: Sebastian Thiel, Michael Trier
|
|
@@ -29,8 +29,16 @@ License-File: LICENSE
|
|
|
29
29
|
License-File: AUTHORS
|
|
30
30
|
Requires-Dist: gitdb <5,>=4.0.1
|
|
31
31
|
Requires-Dist: typing-extensions >=3.7.4.3 ; python_version < "3.8"
|
|
32
|
+
Provides-Extra: doc
|
|
33
|
+
Requires-Dist: sphinx ==4.3.2 ; extra == 'doc'
|
|
34
|
+
Requires-Dist: sphinx-rtd-theme ; extra == 'doc'
|
|
35
|
+
Requires-Dist: sphinxcontrib-applehelp <=1.0.4,>=1.0.2 ; extra == 'doc'
|
|
36
|
+
Requires-Dist: sphinxcontrib-devhelp ==1.0.2 ; extra == 'doc'
|
|
37
|
+
Requires-Dist: sphinxcontrib-htmlhelp <=2.0.1,>=2.0.0 ; extra == 'doc'
|
|
38
|
+
Requires-Dist: sphinxcontrib-qthelp ==1.0.3 ; extra == 'doc'
|
|
39
|
+
Requires-Dist: sphinxcontrib-serializinghtml ==1.1.5 ; extra == 'doc'
|
|
40
|
+
Requires-Dist: sphinx-autodoc-typehints ; extra == 'doc'
|
|
32
41
|
Provides-Extra: test
|
|
33
|
-
Requires-Dist: black ; extra == 'test'
|
|
34
42
|
Requires-Dist: coverage[toml] ; extra == 'test'
|
|
35
43
|
Requires-Dist: ddt !=1.4.3,>=1.1.1 ; extra == 'test'
|
|
36
44
|
Requires-Dist: mypy ; extra == 'test'
|
|
@@ -40,6 +48,7 @@ Requires-Dist: pytest-cov ; extra == 'test'
|
|
|
40
48
|
Requires-Dist: pytest-instafail ; extra == 'test'
|
|
41
49
|
Requires-Dist: pytest-mock ; extra == 'test'
|
|
42
50
|
Requires-Dist: pytest-sugar ; extra == 'test'
|
|
51
|
+
Requires-Dist: typing-extensions ; (python_version < "3.11") and extra == 'test'
|
|
43
52
|
Requires-Dist: mock ; (python_version < "3.8") and extra == 'test'
|
|
44
53
|
|
|
45
54
|

|
|
@@ -61,7 +70,7 @@ probably the skills to scratch that itch of mine: implement `git` in a way that
|
|
|
61
70
|
If you like the idea and want to learn more, please head over to [gitoxide](https://github.com/Byron/gitoxide), an
|
|
62
71
|
implementation of 'git' in [Rust](https://www.rust-lang.org).
|
|
63
72
|
|
|
64
|
-
*(Please note that `gitoxide` is not currently available for use in Python, and that Rust is required)*
|
|
73
|
+
*(Please note that `gitoxide` is not currently available for use in Python, and that Rust is required.)*
|
|
65
74
|
|
|
66
75
|
## GitPython
|
|
67
76
|
|
|
@@ -83,9 +92,9 @@ The project is open to contributions of all kinds, as well as new maintainers.
|
|
|
83
92
|
|
|
84
93
|
### REQUIREMENTS
|
|
85
94
|
|
|
86
|
-
GitPython needs the `git` executable to be installed on the system and available in your
|
|
87
|
-
If it is not in your `PATH`, you can help GitPython find it
|
|
88
|
-
the `GIT_PYTHON_GIT_EXECUTABLE=<path/to/git>` environment variable.
|
|
95
|
+
GitPython needs the `git` executable to be installed on the system and available in your
|
|
96
|
+
`PATH` for most operations. If it is not in your `PATH`, you can help GitPython find it
|
|
97
|
+
by setting the `GIT_PYTHON_GIT_EXECUTABLE=<path/to/git>` environment variable.
|
|
89
98
|
|
|
90
99
|
- Git (1.7.x or newer)
|
|
91
100
|
- Python >= 3.7
|
|
@@ -101,7 +110,7 @@ GitPython and its required package dependencies can be installed in any of the f
|
|
|
101
110
|
|
|
102
111
|
To obtain and install a copy [from PyPI](https://pypi.org/project/GitPython/), run:
|
|
103
112
|
|
|
104
|
-
```
|
|
113
|
+
```sh
|
|
105
114
|
pip install GitPython
|
|
106
115
|
```
|
|
107
116
|
|
|
@@ -111,7 +120,7 @@ pip install GitPython
|
|
|
111
120
|
|
|
112
121
|
If you have downloaded the source code, run this from inside the unpacked `GitPython` directory:
|
|
113
122
|
|
|
114
|
-
```
|
|
123
|
+
```sh
|
|
115
124
|
pip install .
|
|
116
125
|
```
|
|
117
126
|
|
|
@@ -119,7 +128,7 @@ pip install .
|
|
|
119
128
|
|
|
120
129
|
To clone the [the GitHub repository](https://github.com/gitpython-developers/GitPython) from source to work on the code, you can do it like so:
|
|
121
130
|
|
|
122
|
-
```
|
|
131
|
+
```sh
|
|
123
132
|
git clone https://github.com/gitpython-developers/GitPython
|
|
124
133
|
cd GitPython
|
|
125
134
|
./init-tests-after-clone.sh
|
|
@@ -129,7 +138,7 @@ On Windows, `./init-tests-after-clone.sh` can be run in a Git Bash shell.
|
|
|
129
138
|
|
|
130
139
|
If you are cloning [your own fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks), then replace the above `git clone` command with one that gives the URL of your fork. Or use this [`gh`](https://cli.github.com/) command (assuming you have `gh` and your fork is called `GitPython`):
|
|
131
140
|
|
|
132
|
-
```
|
|
141
|
+
```sh
|
|
133
142
|
gh repo clone GitPython
|
|
134
143
|
```
|
|
135
144
|
|
|
@@ -137,7 +146,7 @@ Having cloned the repo, create and activate your [virtual environment](https://d
|
|
|
137
146
|
|
|
138
147
|
Then make an [editable install](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs):
|
|
139
148
|
|
|
140
|
-
```
|
|
149
|
+
```sh
|
|
141
150
|
pip install -e ".[test]"
|
|
142
151
|
```
|
|
143
152
|
|
|
@@ -149,7 +158,7 @@ In rare cases, you may want to work on GitPython and one or both of its [gitdb](
|
|
|
149
158
|
|
|
150
159
|
If you want to do that *and* you want the versions in GitPython's git submodules to be used, then pass `-e git/ext/gitdb` and/or `-e git/ext/gitdb/gitdb/ext/smmap` to `pip install`. This can be done in any order, and in separate `pip install` commands or the same one, so long as `-e` appears before *each* path. For example, you can install GitPython, gitdb, and smmap editably in the currently active virtual environment this way:
|
|
151
160
|
|
|
152
|
-
```
|
|
161
|
+
```sh
|
|
153
162
|
pip install -e ".[test]" -e git/ext/gitdb -e git/ext/gitdb/gitdb/ext/smmap
|
|
154
163
|
```
|
|
155
164
|
|
|
@@ -185,42 +194,38 @@ you will encounter test failures.
|
|
|
185
194
|
|
|
186
195
|
Ensure testing libraries are installed. This is taken care of already if you installed with:
|
|
187
196
|
|
|
188
|
-
```
|
|
197
|
+
```sh
|
|
189
198
|
pip install -e ".[test]"
|
|
190
199
|
```
|
|
191
200
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
```bash
|
|
195
|
-
pip install -r test-requirements.txt
|
|
196
|
-
```
|
|
201
|
+
If you had installed with a command like `pip install -e .` instead, you can still run
|
|
202
|
+
the above command to add the testing dependencies.
|
|
197
203
|
|
|
198
204
|
#### Test commands
|
|
199
205
|
|
|
200
206
|
To test, run:
|
|
201
207
|
|
|
202
|
-
```
|
|
208
|
+
```sh
|
|
203
209
|
pytest
|
|
204
210
|
```
|
|
205
211
|
|
|
206
|
-
To lint, and apply automatic code formatting, run:
|
|
212
|
+
To lint, and apply some linting fixes as well as automatic code formatting, run:
|
|
207
213
|
|
|
208
|
-
```
|
|
214
|
+
```sh
|
|
209
215
|
pre-commit run --all-files
|
|
210
216
|
```
|
|
211
217
|
|
|
212
|
-
|
|
213
|
-
- Auto-formatting without other lint checks can be done with: `black .`
|
|
218
|
+
This includes the linting and autoformatting done by Ruff, as well as some other checks.
|
|
214
219
|
|
|
215
220
|
To typecheck, run:
|
|
216
221
|
|
|
217
|
-
```
|
|
218
|
-
mypy
|
|
222
|
+
```sh
|
|
223
|
+
mypy
|
|
219
224
|
```
|
|
220
225
|
|
|
221
226
|
#### CI (and tox)
|
|
222
227
|
|
|
223
|
-
|
|
228
|
+
Style and formatting checks, and running tests on all the different supported Python versions, will be performed:
|
|
224
229
|
|
|
225
230
|
- Upon submitting a pull request.
|
|
226
231
|
- On each push, *if* you have a fork with GitHub Actions enabled.
|
|
@@ -228,10 +233,12 @@ The same linting, and running tests on all the different supported Python versio
|
|
|
228
233
|
|
|
229
234
|
#### Configuration files
|
|
230
235
|
|
|
231
|
-
Specific tools:
|
|
236
|
+
Specific tools are all configured in the `./pyproject.toml` file:
|
|
232
237
|
|
|
233
|
-
-
|
|
234
|
-
-
|
|
238
|
+
- `pytest` (test runner)
|
|
239
|
+
- `coverage.py` (code coverage)
|
|
240
|
+
- `ruff` (linter and formatter)
|
|
241
|
+
- `mypy` (type checker)
|
|
235
242
|
|
|
236
243
|
Orchestration tools:
|
|
237
244
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
git/__init__.py,sha256=w6fnS0QmwTfEFUSL6rfnpP0lUId2goSguZFOvVX3N3U,8899
|
|
2
|
+
git/cmd.py,sha256=qd-gIHSk4mfsYjd9YA08cPyO8TMxaibTXAbFnHK71uc,67659
|
|
3
|
+
git/compat.py,sha256=y1E6y6O2q5r8clSlr8ZNmuIWG9nmHuehQEsVsmBffs8,4526
|
|
4
|
+
git/config.py,sha256=Ald8Xc-G9Shcgx3QCISyXTkL4a6nbc3qll-xUw4YdyY,34924
|
|
5
|
+
git/db.py,sha256=vIW9uWSbqu99zbuU2ZDmOhVOv1UPTmxrnqiCtRHCfjE,2368
|
|
6
|
+
git/diff.py,sha256=IE5aeHL7aP9yxBluYj06IX8nZjoJ_TOM3gG31-Evf_8,27058
|
|
7
|
+
git/exc.py,sha256=Gc7g1pHpn8OmTse30NHmJVsBJ2CYH8LxaR8y8UA3lIM,7119
|
|
8
|
+
git/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
git/remote.py,sha256=IHQ3BvXgoIN1EvHlyH3vrSaQoDkLOE6nooSC0w183sU,46561
|
|
10
|
+
git/types.py,sha256=xCwpp2Y01lhS0MapHhj04m0P_x34kwSD1Gsou_ZPWj8,10251
|
|
11
|
+
git/util.py,sha256=1E883mnPAFLyFk7ivwnEremsp-uJOTc3ks_QypyLung,43651
|
|
12
|
+
git/index/__init__.py,sha256=i-Nqb8Lufp9aFbmxpQBORmmQnjEVVM1Pn58fsQkyGgQ,406
|
|
13
|
+
git/index/base.py,sha256=A4q4cN_Ifxi8CsAR-7h4KsQ2d3JazBNFZ1ltbAKttgs,60734
|
|
14
|
+
git/index/fun.py,sha256=37cA3DBC9vpAnSVu5TGA072SnoF5XZOkOukExwlejHs,16736
|
|
15
|
+
git/index/typ.py,sha256=uuKNwitUw83FhVaLSwo4pY7PHDQudtZTLJrLGym4jcI,6570
|
|
16
|
+
git/index/util.py,sha256=fULi7GPG-MvprKrRCD5c15GNdzku_1E38We0d97WB3A,3659
|
|
17
|
+
git/objects/__init__.py,sha256=O6ZL_olX7e5-8iIbKviRPkVSJxN37WA-EC0q9d48U5Y,637
|
|
18
|
+
git/objects/base.py,sha256=0dqNkSRVH0mk0-7ZKIkGBK7iNYrzLTVxwQFUd6CagsE,10277
|
|
19
|
+
git/objects/blob.py,sha256=zwwq0KfOMYeP5J2tW5CQatoLyeqFRlfkxP1Vwx1h07s,1215
|
|
20
|
+
git/objects/commit.py,sha256=vLZNl1I9zp17Rpge7J66CvsryirEs90jyPTQzoP0JJs,30208
|
|
21
|
+
git/objects/fun.py,sha256=B4jCqhAjm6Hl79GK58FPzW1H9K6Wc7Tx0rssyWmAcEE,8935
|
|
22
|
+
git/objects/tag.py,sha256=gAx8i-DEwy_Z3R2zLkvetYRV8A56BCcTr3iLuTUTfEM,4467
|
|
23
|
+
git/objects/tree.py,sha256=jJH888SHiP4dGzE-ra1yenQOyya_0C_MkHr06c1gHpM,13849
|
|
24
|
+
git/objects/util.py,sha256=Ml2eqZPKO4y9Hc2vWbXJgpsK3nkN3KGMzbn8AlzLyYQ,23834
|
|
25
|
+
git/objects/submodule/__init__.py,sha256=6xySp767LVz3UylWgUalntS_nGXRuVzXxDuFAv_Wc2c,303
|
|
26
|
+
git/objects/submodule/base.py,sha256=MQ-2xV8JznGwy2hLQv1aeQNgAkhBhgc5tdtClFL3DmE,63901
|
|
27
|
+
git/objects/submodule/root.py,sha256=5eTtYNHasqdPq6q0oDCPr7IaO6uAHL3b4DxMoiO2LhE,20246
|
|
28
|
+
git/objects/submodule/util.py,sha256=sQqAYaiSJdFkZa9NlAuK_wTsMNiS-kkQnQjvIoJtc_o,3509
|
|
29
|
+
git/refs/__init__.py,sha256=DWlJNnsx-4jM_E-VycbP-FZUdn6iWhjnH_uZ_pZXBro,509
|
|
30
|
+
git/refs/head.py,sha256=GAZpD5EfqSciDXPtgjHY8ZbBixKExJRhojUB-HrrJPg,10491
|
|
31
|
+
git/refs/log.py,sha256=kXiuAgTo1DIuM_BfbDUk9gQ0YO-mutIMVdHv1_ES90o,12493
|
|
32
|
+
git/refs/reference.py,sha256=l6mhF4YLSEwtjz6b9PpOQH-fkng7EYWMaJhkjn-2jXA,5630
|
|
33
|
+
git/refs/remote.py,sha256=WwqV9T7BbYf3F_WZNUQivu9xktIIKGklCjDpwQrhD-A,2806
|
|
34
|
+
git/refs/symbolic.py,sha256=c8zOwaqzcg-J-rGrpuWdvh8zwMvSUqAHghd4vJoYG_s,34552
|
|
35
|
+
git/refs/tag.py,sha256=kgzV2vhpL4FD2TqHb0BJuMRAHgAvJF-TcoyWlaB-djQ,5010
|
|
36
|
+
git/repo/__init__.py,sha256=CILSVH36fX_WxVFSjD9o1WF5LgsNedPiJvSngKZqfVU,210
|
|
37
|
+
git/repo/base.py,sha256=mitfJ8u99CsMpDd7_VRyx-SF8omu2tpf3lqzSaQkKoQ,59353
|
|
38
|
+
git/repo/fun.py,sha256=tEsClpmbOrKMSNIdncOB_6JdikrL1-AfkOFd7xMpD8k,13582
|
|
39
|
+
GitPython-3.1.43.dist-info/AUTHORS,sha256=h1TlPKfp05GA1eKQ15Yl4biR0C0FgivuGSeRA6Q1dz0,2286
|
|
40
|
+
GitPython-3.1.43.dist-info/LICENSE,sha256=hvyUwyGpr7wRUUcTURuv3tIl8lEA3MD3NQ6CvCMbi-s,1503
|
|
41
|
+
GitPython-3.1.43.dist-info/METADATA,sha256=sAh3r1BMVw5_olGgDmpMS69zBpVr7UEOeRivNHKznfU,13376
|
|
42
|
+
GitPython-3.1.43.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
43
|
+
GitPython-3.1.43.dist-info/top_level.txt,sha256=0hzDuIp8obv624V3GmbqsagBWkk8ohtGU-Bc1PmTT0o,4
|
|
44
|
+
GitPython-3.1.43.dist-info/RECORD,,
|
git/__init__.py
CHANGED
|
@@ -5,39 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
# @PydevCodeAnalysisIgnore
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING
|
|
11
|
-
|
|
12
|
-
from gitdb.util import to_hex_sha
|
|
13
|
-
from git.exc import * # noqa: F403 # @NoMove @IgnorePep8
|
|
14
|
-
from git.types import PathLike
|
|
15
|
-
|
|
16
|
-
try:
|
|
17
|
-
from git.compat import safe_decode # @NoMove @IgnorePep8
|
|
18
|
-
from git.config import GitConfigParser # @NoMove @IgnorePep8
|
|
19
|
-
from git.objects import * # noqa: F403 # @NoMove @IgnorePep8
|
|
20
|
-
from git.refs import * # noqa: F403 # @NoMove @IgnorePep8
|
|
21
|
-
from git.diff import * # noqa: F403 # @NoMove @IgnorePep8
|
|
22
|
-
from git.db import * # noqa: F403 # @NoMove @IgnorePep8
|
|
23
|
-
from git.cmd import Git # @NoMove @IgnorePep8
|
|
24
|
-
from git.repo import Repo # @NoMove @IgnorePep8
|
|
25
|
-
from git.remote import * # noqa: F403 # @NoMove @IgnorePep8
|
|
26
|
-
from git.index import * # noqa: F403 # @NoMove @IgnorePep8
|
|
27
|
-
from git.util import ( # @NoMove @IgnorePep8
|
|
28
|
-
LockFile,
|
|
29
|
-
BlockingLockFile,
|
|
30
|
-
Stats,
|
|
31
|
-
Actor,
|
|
32
|
-
remove_password_if_present,
|
|
33
|
-
rmtree,
|
|
34
|
-
)
|
|
35
|
-
except GitError as _exc: # noqa: F405
|
|
36
|
-
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc
|
|
37
|
-
|
|
38
|
-
# __all__ must be statically defined by py.typed support
|
|
39
|
-
# __all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))]
|
|
40
|
-
__all__ = [ # noqa: F405
|
|
8
|
+
__all__ = [
|
|
41
9
|
"Actor",
|
|
42
10
|
"AmbiguousObjectName",
|
|
43
11
|
"BadName",
|
|
@@ -52,6 +20,7 @@ __all__ = [ # noqa: F405
|
|
|
52
20
|
"CommandError",
|
|
53
21
|
"Commit",
|
|
54
22
|
"Diff",
|
|
23
|
+
"DiffConstants",
|
|
55
24
|
"DiffIndex",
|
|
56
25
|
"Diffable",
|
|
57
26
|
"FetchInfo",
|
|
@@ -65,18 +34,19 @@ __all__ = [ # noqa: F405
|
|
|
65
34
|
"HEAD",
|
|
66
35
|
"Head",
|
|
67
36
|
"HookExecutionError",
|
|
37
|
+
"INDEX",
|
|
68
38
|
"IndexEntry",
|
|
69
39
|
"IndexFile",
|
|
70
40
|
"IndexObject",
|
|
71
41
|
"InvalidDBRoot",
|
|
72
42
|
"InvalidGitRepositoryError",
|
|
73
|
-
"List",
|
|
43
|
+
"List", # Deprecated - import this from `typing` instead.
|
|
74
44
|
"LockFile",
|
|
75
45
|
"NULL_TREE",
|
|
76
46
|
"NoSuchPathError",
|
|
77
47
|
"ODBError",
|
|
78
48
|
"Object",
|
|
79
|
-
"Optional",
|
|
49
|
+
"Optional", # Deprecated - import this from `typing` instead.
|
|
80
50
|
"ParseError",
|
|
81
51
|
"PathLike",
|
|
82
52
|
"PushInfo",
|
|
@@ -90,54 +60,241 @@ __all__ = [ # noqa: F405
|
|
|
90
60
|
"RepositoryDirtyError",
|
|
91
61
|
"RootModule",
|
|
92
62
|
"RootUpdateProgress",
|
|
93
|
-
"Sequence",
|
|
63
|
+
"Sequence", # Deprecated - import from `typing`, or `collections.abc` in 3.9+.
|
|
94
64
|
"StageType",
|
|
95
65
|
"Stats",
|
|
96
66
|
"Submodule",
|
|
97
67
|
"SymbolicReference",
|
|
98
|
-
"TYPE_CHECKING",
|
|
68
|
+
"TYPE_CHECKING", # Deprecated - import this from `typing` instead.
|
|
99
69
|
"Tag",
|
|
100
70
|
"TagObject",
|
|
101
71
|
"TagReference",
|
|
102
72
|
"Tree",
|
|
103
73
|
"TreeModifier",
|
|
104
|
-
"Tuple",
|
|
105
|
-
"Union",
|
|
74
|
+
"Tuple", # Deprecated - import this from `typing` instead.
|
|
75
|
+
"Union", # Deprecated - import this from `typing` instead.
|
|
106
76
|
"UnmergedEntriesError",
|
|
107
77
|
"UnsafeOptionError",
|
|
108
78
|
"UnsafeProtocolError",
|
|
109
79
|
"UnsupportedOperation",
|
|
110
80
|
"UpdateProgress",
|
|
111
81
|
"WorkTreeRepositoryUnsupported",
|
|
82
|
+
"refresh",
|
|
112
83
|
"remove_password_if_present",
|
|
113
84
|
"rmtree",
|
|
114
85
|
"safe_decode",
|
|
115
86
|
"to_hex_sha",
|
|
116
87
|
]
|
|
117
88
|
|
|
89
|
+
__version__ = '3.1.43'
|
|
90
|
+
|
|
91
|
+
from typing import Any, List, Optional, Sequence, TYPE_CHECKING, Tuple, Union
|
|
92
|
+
|
|
93
|
+
if TYPE_CHECKING:
|
|
94
|
+
from types import ModuleType
|
|
95
|
+
|
|
96
|
+
import warnings
|
|
97
|
+
|
|
98
|
+
from gitdb.util import to_hex_sha
|
|
99
|
+
|
|
100
|
+
from git.exc import (
|
|
101
|
+
AmbiguousObjectName,
|
|
102
|
+
BadName,
|
|
103
|
+
BadObject,
|
|
104
|
+
BadObjectType,
|
|
105
|
+
CacheError,
|
|
106
|
+
CheckoutError,
|
|
107
|
+
CommandError,
|
|
108
|
+
GitCommandError,
|
|
109
|
+
GitCommandNotFound,
|
|
110
|
+
GitError,
|
|
111
|
+
HookExecutionError,
|
|
112
|
+
InvalidDBRoot,
|
|
113
|
+
InvalidGitRepositoryError,
|
|
114
|
+
NoSuchPathError,
|
|
115
|
+
ODBError,
|
|
116
|
+
ParseError,
|
|
117
|
+
RepositoryDirtyError,
|
|
118
|
+
UnmergedEntriesError,
|
|
119
|
+
UnsafeOptionError,
|
|
120
|
+
UnsafeProtocolError,
|
|
121
|
+
UnsupportedOperation,
|
|
122
|
+
WorkTreeRepositoryUnsupported,
|
|
123
|
+
)
|
|
124
|
+
from git.types import PathLike
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
from git.compat import safe_decode # @NoMove
|
|
128
|
+
from git.config import GitConfigParser # @NoMove
|
|
129
|
+
from git.objects import ( # @NoMove
|
|
130
|
+
Blob,
|
|
131
|
+
Commit,
|
|
132
|
+
IndexObject,
|
|
133
|
+
Object,
|
|
134
|
+
RootModule,
|
|
135
|
+
RootUpdateProgress,
|
|
136
|
+
Submodule,
|
|
137
|
+
TagObject,
|
|
138
|
+
Tree,
|
|
139
|
+
TreeModifier,
|
|
140
|
+
UpdateProgress,
|
|
141
|
+
)
|
|
142
|
+
from git.refs import ( # @NoMove
|
|
143
|
+
HEAD,
|
|
144
|
+
Head,
|
|
145
|
+
RefLog,
|
|
146
|
+
RefLogEntry,
|
|
147
|
+
Reference,
|
|
148
|
+
RemoteReference,
|
|
149
|
+
SymbolicReference,
|
|
150
|
+
Tag,
|
|
151
|
+
TagReference,
|
|
152
|
+
)
|
|
153
|
+
from git.diff import ( # @NoMove
|
|
154
|
+
INDEX,
|
|
155
|
+
NULL_TREE,
|
|
156
|
+
Diff,
|
|
157
|
+
DiffConstants,
|
|
158
|
+
DiffIndex,
|
|
159
|
+
Diffable,
|
|
160
|
+
)
|
|
161
|
+
from git.db import GitCmdObjectDB, GitDB # @NoMove
|
|
162
|
+
from git.cmd import Git # @NoMove
|
|
163
|
+
from git.repo import Repo # @NoMove
|
|
164
|
+
from git.remote import FetchInfo, PushInfo, Remote, RemoteProgress # @NoMove
|
|
165
|
+
from git.index import ( # @NoMove
|
|
166
|
+
BaseIndexEntry,
|
|
167
|
+
BlobFilter,
|
|
168
|
+
CheckoutError,
|
|
169
|
+
IndexEntry,
|
|
170
|
+
IndexFile,
|
|
171
|
+
StageType,
|
|
172
|
+
# NOTE: This tells type checkers what util resolves to. We delete it, and it is
|
|
173
|
+
# really resolved by __getattr__, which warns. See below on what to use instead.
|
|
174
|
+
util,
|
|
175
|
+
)
|
|
176
|
+
from git.util import ( # @NoMove
|
|
177
|
+
Actor,
|
|
178
|
+
BlockingLockFile,
|
|
179
|
+
LockFile,
|
|
180
|
+
Stats,
|
|
181
|
+
remove_password_if_present,
|
|
182
|
+
rmtree,
|
|
183
|
+
)
|
|
184
|
+
except GitError as _exc:
|
|
185
|
+
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _warned_import(message: str, fullname: str) -> "ModuleType":
|
|
189
|
+
import importlib
|
|
190
|
+
|
|
191
|
+
warnings.warn(message, DeprecationWarning, stacklevel=3)
|
|
192
|
+
return importlib.import_module(fullname)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _getattr(name: str) -> Any:
|
|
196
|
+
# TODO: If __version__ is made dynamic and lazily fetched, put that case right here.
|
|
197
|
+
|
|
198
|
+
if name == "util":
|
|
199
|
+
return _warned_import(
|
|
200
|
+
"The expression `git.util` and the import `from git import util` actually "
|
|
201
|
+
"reference git.index.util, and not the git.util module accessed in "
|
|
202
|
+
'`from git.util import XYZ` or `sys.modules["git.util"]`. This potentially '
|
|
203
|
+
"confusing behavior is currently preserved for compatibility, but may be "
|
|
204
|
+
"changed in the future and should not be relied on.",
|
|
205
|
+
fullname="git.index.util",
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
for names, prefix in (
|
|
209
|
+
({"head", "log", "reference", "symbolic", "tag"}, "git.refs"),
|
|
210
|
+
({"base", "fun", "typ"}, "git.index"),
|
|
211
|
+
):
|
|
212
|
+
if name not in names:
|
|
213
|
+
continue
|
|
214
|
+
|
|
215
|
+
fullname = f"{prefix}.{name}"
|
|
216
|
+
|
|
217
|
+
return _warned_import(
|
|
218
|
+
f"{__name__}.{name} is a private alias of {fullname} and subject to "
|
|
219
|
+
f"immediate removal. Use {fullname} instead.",
|
|
220
|
+
fullname=fullname,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
if not TYPE_CHECKING:
|
|
227
|
+
# NOTE: The expression `git.util` gives git.index.util and `from git import util`
|
|
228
|
+
# imports git.index.util, NOT git.util. It may not be feasible to change this until
|
|
229
|
+
# the next major version, to avoid breaking code inadvertently relying on it.
|
|
230
|
+
#
|
|
231
|
+
# - If git.index.util *is* what you want, use (or import from) that, to avoid
|
|
232
|
+
# confusion.
|
|
233
|
+
#
|
|
234
|
+
# - To use the "real" git.util module, write `from git.util import ...`, or if
|
|
235
|
+
# necessary access it as `sys.modules["git.util"]`.
|
|
236
|
+
#
|
|
237
|
+
# Note also that `import git.util` technically imports the "real" git.util... but
|
|
238
|
+
# the *expression* `git.util` after doing so is still git.index.util!
|
|
239
|
+
#
|
|
240
|
+
# (This situation differs from that of other indirect-submodule imports that are
|
|
241
|
+
# unambiguously non-public and subject to immediate removal. Here, the public
|
|
242
|
+
# git.util module, though different, makes less discoverable that the expression
|
|
243
|
+
# `git.util` refers to a non-public attribute of the git module.)
|
|
244
|
+
#
|
|
245
|
+
# This had originally come about by a wildcard import. Now that all intended imports
|
|
246
|
+
# are explicit, the intuitive but potentially incompatible binding occurs due to the
|
|
247
|
+
# usual rules for Python submodule bindings. So for now we replace that binding with
|
|
248
|
+
# git.index.util, delete that, and let __getattr__ handle it and issue a warning.
|
|
249
|
+
#
|
|
250
|
+
# For the same runtime behavior, it would be enough to forgo importing util, and
|
|
251
|
+
# delete util as created naturally; __getattr__ would behave the same. But type
|
|
252
|
+
# checkers would not know what util refers to when accessed as an attribute of git.
|
|
253
|
+
del util
|
|
254
|
+
|
|
255
|
+
# This is "hidden" to preserve static checking for undefined/misspelled attributes.
|
|
256
|
+
__getattr__ = _getattr
|
|
257
|
+
|
|
118
258
|
# { Initialize git executable path
|
|
259
|
+
|
|
119
260
|
GIT_OK = None
|
|
120
261
|
|
|
121
262
|
|
|
122
263
|
def refresh(path: Optional[PathLike] = None) -> None:
|
|
123
|
-
"""Convenience method for setting the git executable path.
|
|
264
|
+
"""Convenience method for setting the git executable path.
|
|
265
|
+
|
|
266
|
+
:param path:
|
|
267
|
+
Optional path to the Git executable. If not absolute, it is resolved
|
|
268
|
+
immediately, relative to the current directory.
|
|
269
|
+
|
|
270
|
+
:note:
|
|
271
|
+
The `path` parameter is usually omitted and cannot be used to specify a custom
|
|
272
|
+
command whose location is looked up in a path search on each call. See
|
|
273
|
+
:meth:`Git.refresh <git.cmd.Git.refresh>` for details on how to achieve this.
|
|
274
|
+
|
|
275
|
+
:note:
|
|
276
|
+
This calls :meth:`Git.refresh <git.cmd.Git.refresh>` and sets other global
|
|
277
|
+
configuration according to the effect of doing so. As such, this function should
|
|
278
|
+
usually be used instead of using :meth:`Git.refresh <git.cmd.Git.refresh>` or
|
|
279
|
+
:meth:`FetchInfo.refresh <git.remote.FetchInfo.refresh>` directly.
|
|
280
|
+
|
|
281
|
+
:note:
|
|
282
|
+
This function is called automatically, with no arguments, at import time.
|
|
283
|
+
"""
|
|
124
284
|
global GIT_OK
|
|
125
285
|
GIT_OK = False
|
|
126
286
|
|
|
127
287
|
if not Git.refresh(path=path):
|
|
128
288
|
return
|
|
129
289
|
if not FetchInfo.refresh(): # noqa: F405
|
|
130
|
-
return # type: ignore
|
|
290
|
+
return # type: ignore[unreachable]
|
|
131
291
|
|
|
132
292
|
GIT_OK = True
|
|
133
293
|
|
|
134
294
|
|
|
135
|
-
# } END initialize git executable path
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
#################
|
|
139
295
|
try:
|
|
140
296
|
refresh()
|
|
141
297
|
except Exception as _exc:
|
|
142
298
|
raise ImportError("Failed to initialize: {0}".format(_exc)) from _exc
|
|
143
|
-
|
|
299
|
+
|
|
300
|
+
# } END initialize git executable path
|