GitPython 3.1.34__py3-none-any.whl → 3.1.36__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.
@@ -51,4 +51,5 @@ Contributors are:
51
51
  -Luke Twist <itsluketwist@gmail.com>
52
52
  -Joseph Hale <me _at_ jhale.dev>
53
53
  -Santos Gallegos <stsewd _at_ proton.me>
54
+ -Wenhan Zhu <wzhu.cosmos _at_ gmail.com>
54
55
  Portions derived from other open source works and are clearly marked.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: GitPython
3
- Version: 3.1.34
3
+ Version: 3.1.36
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
@@ -22,12 +22,23 @@ Classifier: Programming Language :: Python :: 3.8
22
22
  Classifier: Programming Language :: Python :: 3.9
23
23
  Classifier: Programming Language :: Python :: 3.10
24
24
  Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
25
26
  Requires-Python: >=3.7
26
27
  Description-Content-Type: text/markdown
27
28
  License-File: LICENSE
28
29
  License-File: AUTHORS
29
30
  Requires-Dist: gitdb <5,>=4.0.1
30
31
  Requires-Dist: typing-extensions >=3.7.4.3 ; python_version < "3.8"
32
+ Provides-Extra: test
33
+ Requires-Dist: black ; extra == 'test'
34
+ Requires-Dist: coverage[toml] ; extra == 'test'
35
+ Requires-Dist: ddt !=1.4.3,>=1.1.1 ; extra == 'test'
36
+ Requires-Dist: mypy ; extra == 'test'
37
+ Requires-Dist: pre-commit ; extra == 'test'
38
+ Requires-Dist: pytest ; extra == 'test'
39
+ Requires-Dist: pytest-cov ; extra == 'test'
40
+ Requires-Dist: pytest-sugar ; extra == 'test'
41
+ Requires-Dist: virtualenv ; extra == 'test'
31
42
 
32
43
  ![Python package](https://github.com/gitpython-developers/GitPython/workflows/Python%20package/badge.svg)
33
44
  [![Documentation Status](https://readthedocs.org/projects/gitpython/badge/?version=stable)](https://readthedocs.org/projects/gitpython/?badge=stable)
@@ -80,30 +91,51 @@ The installer takes care of installing them for you.
80
91
 
81
92
  ### INSTALL
82
93
 
83
- If you have downloaded the source code:
94
+ GitPython and its required package dependencies can be installed in any of the following ways, all of which should typically be done in a [virtual environment](https://docs.python.org/3/tutorial/venv.html).
84
95
 
85
- ```bash
86
- python setup.py install
87
- ```
96
+ #### From PyPI
88
97
 
89
- or if you want to obtain a copy from the Pypi repository:
98
+ To obtain and install a copy [from PyPI](https://pypi.org/project/GitPython/), run:
90
99
 
91
100
  ```bash
92
101
  pip install GitPython
93
102
  ```
94
103
 
95
- Both commands will install the required package dependencies.
104
+ (A distribution package can also be downloaded for manual installation at [the PyPI page](https://pypi.org/project/GitPython/).)
105
+
106
+ #### From downloaded source code
107
+
108
+ If you have downloaded the source code, run this from inside the unpacked `GitPython` directory:
109
+
110
+ ```bash
111
+ pip install .
112
+ ```
96
113
 
97
- A distribution package can be obtained for manual installation at: <http://pypi.python.org/pypi/GitPython>.
114
+ #### By cloning the source code repository
98
115
 
99
- If you like to clone from source, you can do it like so:
116
+ 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:
100
117
 
101
118
  ```bash
102
119
  git clone https://github.com/gitpython-developers/GitPython
103
- git submodule update --init --recursive
120
+ cd GitPython
121
+ git fetch --tags
104
122
  ./init-tests-after-clone.sh
105
123
  ```
106
124
 
125
+ 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`):
126
+
127
+ ```bash
128
+ gh repo clone GitPython
129
+ ```
130
+
131
+ Having cloned the repo, create and activate your [virtual environment](https://docs.python.org/3/tutorial/venv.html). Then make an [editable install](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs):
132
+
133
+ ```bash
134
+ pip install -e ".[test]"
135
+ ```
136
+
137
+ In the less common case that you do not want to install test dependencies, `pip install -e .` can be used instead.
138
+
107
139
  ### Limitations
108
140
 
109
141
  #### Leakage of System Resources
@@ -124,28 +156,57 @@ See [Issue #525](https://github.com/gitpython-developers/GitPython/issues/525).
124
156
 
125
157
  ### RUNNING TESTS
126
158
 
127
- _Important_: Right after cloning this repository, please be sure to have executed
128
- the `./init-tests-after-clone.sh` script in the repository root. Otherwise
129
- you will encounter test failures.
159
+ _Important_: Right after cloning this repository, please be sure to have
160
+ executed `git fetch --tags` followed by the `./init-tests-after-clone.sh`
161
+ script in the repository root. Otherwise you will encounter test failures.
130
162
 
131
163
  On _Windows_, make sure you have `git-daemon` in your PATH. For MINGW-git, the `git-daemon.exe`
132
164
  exists in `Git\mingw64\libexec\git-core\`; CYGWIN has no daemon, but should get along fine
133
165
  with MINGW's.
134
166
 
135
- Ensure testing libraries are installed.
136
- In the root directory, run: `pip install -r test-requirements.txt`
167
+ #### Install test dependencies
137
168
 
138
- To lint, run: `pre-commit run --all-files`
169
+ Ensure testing libraries are installed. This is taken care of already if you installed with:
139
170
 
140
- To typecheck, run: `mypy -p git`
171
+ ```bash
172
+ pip install -e ".[test]"
173
+ ```
141
174
 
142
- To test, run: `pytest`
175
+ Otherwise, you can run:
143
176
 
144
- For automatic code formatting run: `black git`
177
+ ```bash
178
+ pip install -r test-requirements.txt
179
+ ```
180
+
181
+ #### Test commands
182
+
183
+ To test, run:
184
+
185
+ ```bash
186
+ pytest
187
+ ```
188
+
189
+ To lint, run:
190
+
191
+ ```bash
192
+ pre-commit run --all-files
193
+ ```
194
+
195
+ To typecheck, run:
196
+
197
+ ```bash
198
+ mypy -p git
199
+ ```
200
+
201
+ For automatic code formatting, run:
202
+
203
+ ```bash
204
+ black git
205
+ ```
145
206
 
146
- Configuration for flake8 is in the ./.flake8 file.
207
+ Configuration for flake8 is in the `./.flake8` file.
147
208
 
148
- Configurations for mypy, pytest and coverage.py are in ./pyproject.toml.
209
+ Configurations for `mypy`, `pytest`, `coverage.py`, and `black` are in `./pyproject.toml`.
149
210
 
150
211
  The same linting and testing will also be performed against different supported python versions
151
212
  upon submitting a pull request (or on each push if you have a fork with a "main" branch and actions enabled).
@@ -169,13 +230,15 @@ Please have a look at the [contributions file][contributing].
169
230
 
170
231
  ### How to make a new release
171
232
 
172
- - Update/verify the **version** in the `VERSION` file
173
- - Update/verify that the `doc/source/changes.rst` changelog file was updated
174
- - Commit everything
175
- - Run `git tag -s <version>` to tag the version in Git
176
- - Run `make release`
233
+ - Update/verify the **version** in the `VERSION` file.
234
+ - Update/verify that the `doc/source/changes.rst` changelog file was updated.
235
+ - Commit everything.
236
+ - Run `git tag -s <version>` to tag the version in Git.
237
+ - _Optionally_ create and activate a [virtual environment](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment) using `venv` or `virtualenv`.\
238
+ (When run in a virtual environment, the next step will automatically take care of installing `build` and `twine` in it.)
239
+ - Run `make release`.
177
240
  - Close the milestone mentioned in the _changelog_ and create a new one. _Do not reuse milestones by renaming them_.
178
- - Got to [GitHub Releases](https://github.com/gitpython-developers/GitPython/releases) and publish a new one with the recently pushed tag. Generate the changelog.
241
+ - Go to [GitHub Releases](https://github.com/gitpython-developers/GitPython/releases) and publish a new one with the recently pushed tag. Generate the changelog.
179
242
 
180
243
  ### How to verify a release (DEPRECATED)
181
244
 
@@ -1,5 +1,5 @@
1
- git/__init__.py,sha256=D1Xxk-x8AlLUEvwpeBbIaEjfKRX76JAeMXXjZR_UDWw,2379
2
- git/cmd.py,sha256=Js_9VXq-4ss288i-_Ii9ptoCThWBa9v1RS75-f7mxWY,54090
1
+ git/__init__.py,sha256=k6nrx92KdrotIDHFnn1z0bZSxWtvaYZcKkMTaQO1Lsw,2379
2
+ git/cmd.py,sha256=g9VI2IZU7jF4oYf9C1hLDqY6mD10wET_Du8BVZQi_P0,54069
3
3
  git/compat.py,sha256=3wWLkD9QrZvLiV6NtNxJILwGrLE2nw_SoLqaTEPH364,2256
4
4
  git/config.py,sha256=_84Pc5-jF9aNMGHMkF2sE0_UClLDkRD92Hbm7zaqAgw,34578
5
5
  git/db.py,sha256=dEs2Bn-iDuHyero9afw8mrXHrLE7_CDExv943iWU9WI,2244
@@ -8,7 +8,7 @@ git/exc.py,sha256=h5OD3BrolG94u4sS97HlXf8VYYUMQWn_JoUBgKrMrl0,6444
8
8
  git/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  git/remote.py,sha256=LCUY4dmMufudQWrzrzX7hyQKvuZMzwRXtpaWz1Ye-04,45068
10
10
  git/types.py,sha256=y7gKGGB7mEu8VAgo57EXr17t85OXxtp6y58t0-tXk_8,3096
11
- git/util.py,sha256=JNoyKL8vPXgIRNbbDSq2ESRdhZCS5Ia1nU7MbW2JvpI,39746
11
+ git/util.py,sha256=5ITzeAGWkUMi6ZjX3MZRz1kYn5F_s7VxkwBcklV-qWc,40205
12
12
  git/index/__init__.py,sha256=43ovvVNocVRNiQd4fLqvUMuGGmwhBQ9SsiQ46vkvk1E,89
13
13
  git/index/base.py,sha256=9H9pTfhfB4yHysz7HRO39OyfVKqHMacYQBn6QLcpRfk,57492
14
14
  git/index/fun.py,sha256=LovPTfZMkusNQXYIbzrWDqTbTSsF-XT5HBxxD2uAq44,16433
@@ -23,7 +23,7 @@ git/objects/tag.py,sha256=ZXOLK_lV9E5G2aDl5t0hYDN2hhIhGF23HILHBnZgRX0,3840
23
23
  git/objects/tree.py,sha256=cSQbt3nn3cIrbVrBasB1wm2r-vzotYWhka1yDjOHf-k,14230
24
24
  git/objects/util.py,sha256=g7j2D3cdTZ-c1n-22ih3lmSeVXOUEmvwLBG1CsE24aI,22275
25
25
  git/objects/submodule/__init__.py,sha256=OsMeiex7cG6ev2f35IaJ5csH-eXchSoNKCt4HXUG5Ws,93
26
- git/objects/submodule/base.py,sha256=R4jTjBJyMjFOfDAYwsA6Q3Lt6qeFYERPE4PABACW6GE,61539
26
+ git/objects/submodule/base.py,sha256=hiM9J3yW4xEUyJ95lUwcILv9iX7LXq99dtiRN81uvtU,61691
27
27
  git/objects/submodule/root.py,sha256=Ev_RnGzv4hi3UqEFMHuSR-uGR7kYpwOgwZFUG31X-Hc,19568
28
28
  git/objects/submodule/util.py,sha256=u2zQGFWBmryqET0XWf9BuiY1OOgWB8YCU3Wz0xdp4E4,3380
29
29
  git/refs/__init__.py,sha256=PMF97jMUcivbCCEJnl2zTs-YtECNFp8rL8GHK8AitXU,203
@@ -31,14 +31,14 @@ git/refs/head.py,sha256=rZ4LbFd05Gs9sAuSU5VQRDmJZfrwMwWtBpLlmiUQ-Zg,9756
31
31
  git/refs/log.py,sha256=Z8X9_ZGZrVTWz9p_-fk1N3m47G-HTRPwozoZBDd70DI,11892
32
32
  git/refs/reference.py,sha256=DUx7QvYqTBeVxG53ntPfKCp3wuJyDBRIZcPCy1OD22s,5414
33
33
  git/refs/remote.py,sha256=E63Bh5ig1GYrk6FE46iNtS5P6ZgODyPXot8eJw-mxts,2556
34
- git/refs/symbolic.py,sha256=XwfeYr1Zp-fuHAoGuVAXKk4EYlsuUMVu99OjJWuWDTQ,29967
34
+ git/refs/symbolic.py,sha256=nbgWkQlQCj2KZiyfvVTmSU5hilYQp0t7Wm1BSEwAxP8,30065
35
35
  git/refs/tag.py,sha256=FNoCZ3BdDl2i5kD3si2P9hoXU9rDAZ_YK0Rn84TmKT8,4419
36
36
  git/repo/__init__.py,sha256=XMpdeowJRtTEd80jAcrKSQfMu2JZGMfPlpuIYHG2ZCk,80
37
37
  git/repo/base.py,sha256=3iOwwyXSrXPycEEr2dEI-mjl9m_BvV6KrEkYxMspxKE,55134
38
38
  git/repo/fun.py,sha256=VTRODXAb_x8bazkSd8g-Pkk8M2iLVK4kPoKQY9HXjZc,12962
39
- GitPython-3.1.34.dist-info/AUTHORS,sha256=0F09KKrRmwH3zJ4gqo1tJMVlalC9bSunDNKlRvR6q2c,2158
40
- GitPython-3.1.34.dist-info/LICENSE,sha256=_WV__CzvY9JceMq3gI1BTdA6KC5jiTSR_RHDL5i-Z_s,1521
41
- GitPython-3.1.34.dist-info/METADATA,sha256=tSyIQdMqDDUUBYsnGolqfBlosTf0jvfiTx57xbrKEh8,10019
42
- GitPython-3.1.34.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
43
- GitPython-3.1.34.dist-info/top_level.txt,sha256=0hzDuIp8obv624V3GmbqsagBWkk8ohtGU-Bc1PmTT0o,4
44
- GitPython-3.1.34.dist-info/RECORD,,
39
+ GitPython-3.1.36.dist-info/AUTHORS,sha256=MTQl3FsmhgQKZ6l496gsyG82rHY_FdJJ8MgVKbVvU8Y,2199
40
+ GitPython-3.1.36.dist-info/LICENSE,sha256=_WV__CzvY9JceMq3gI1BTdA6KC5jiTSR_RHDL5i-Z_s,1521
41
+ GitPython-3.1.36.dist-info/METADATA,sha256=deOWQkShWVuYb_YV9FTF4900-VW4qVEhfy-UCPSSwms,12249
42
+ GitPython-3.1.36.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
43
+ GitPython-3.1.36.dist-info/top_level.txt,sha256=0hzDuIp8obv624V3GmbqsagBWkk8ohtGU-Bc1PmTT0o,4
44
+ GitPython-3.1.36.dist-info/RECORD,,
git/__init__.py CHANGED
@@ -14,13 +14,13 @@ import os.path as osp
14
14
  from typing import Optional
15
15
  from git.types import PathLike
16
16
 
17
- __version__ = '3.1.34'
17
+ __version__ = '3.1.36'
18
18
 
19
19
 
20
20
  # { Initialization
21
21
  def _init_externals() -> None:
22
22
  """Initialize external projects by putting them into the path"""
23
- if __version__ == '3.1.34' and "PYOXIDIZER" not in os.environ:
23
+ if __version__ == '3.1.36' and "PYOXIDIZER" not in os.environ:
24
24
  sys.path.insert(1, osp.join(osp.dirname(__file__), "ext", "gitdb"))
25
25
 
26
26
  try:
git/cmd.py CHANGED
@@ -14,7 +14,6 @@ from subprocess import call, Popen, PIPE, DEVNULL
14
14
  import subprocess
15
15
  import threading
16
16
  from textwrap import dedent
17
- import unittest.mock
18
17
 
19
18
  from git.compat import (
20
19
  defenc,
@@ -24,7 +23,7 @@ from git.compat import (
24
23
  is_win,
25
24
  )
26
25
  from git.exc import CommandError
27
- from git.util import is_cygwin_git, cygpath, expand_path, remove_password_if_present
26
+ from git.util import is_cygwin_git, cygpath, expand_path, remove_password_if_present, patch_env
28
27
 
29
28
  from .exc import GitCommandError, GitCommandNotFound, UnsafeOptionError, UnsafeProtocolError
30
29
  from .util import (
@@ -965,10 +964,10 @@ class Git(LazyMixin):
965
964
  '"kill_after_timeout" feature is not supported on Windows.',
966
965
  )
967
966
  # Only search PATH, not CWD. This must be in the *caller* environment. The "1" can be any value.
968
- patch_caller_env = unittest.mock.patch.dict(os.environ, {"NoDefaultCurrentDirectoryInExePath": "1"})
967
+ maybe_patch_caller_env = patch_env("NoDefaultCurrentDirectoryInExePath", "1")
969
968
  else:
970
969
  cmd_not_found_exception = FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable
971
- patch_caller_env = contextlib.nullcontext()
970
+ maybe_patch_caller_env = contextlib.nullcontext()
972
971
  # end handle
973
972
 
974
973
  stdout_sink = PIPE if with_stdout else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb")
@@ -984,7 +983,7 @@ class Git(LazyMixin):
984
983
  istream_ok,
985
984
  )
986
985
  try:
987
- with patch_caller_env:
986
+ with maybe_patch_caller_env:
988
987
  proc = Popen(
989
988
  command,
990
989
  env=env,
@@ -1402,6 +1402,10 @@ class Submodule(IndexObject, TraversableIterableObj):
1402
1402
  # END handle keyerror
1403
1403
  # END handle critical error
1404
1404
 
1405
+ # Make sure we are looking at a submodule object
1406
+ if type(sm) != git.objects.submodule.base.Submodule:
1407
+ continue
1408
+
1405
1409
  # fill in remaining info - saves time as it doesn't have to be parsed again
1406
1410
  sm._name = n
1407
1411
  if pc != repo.commit():
git/refs/symbolic.py CHANGED
@@ -168,6 +168,8 @@ class SymbolicReference(object):
168
168
  """Return: (str(sha), str(target_ref_path)) if available, the sha the file at
169
169
  rela_path points to, or None. target_ref_path is the reference we
170
170
  point to, or None"""
171
+ if ".." in str(ref_path):
172
+ raise ValueError(f"Invalid reference '{ref_path}'")
171
173
  tokens: Union[None, List[str], Tuple[str, str]] = None
172
174
  repodir = _git_dir(repo, ref_path)
173
175
  try:
git/util.py CHANGED
@@ -150,6 +150,7 @@ def unbare_repo(func: Callable[..., T]) -> Callable[..., T]:
150
150
 
151
151
  @contextlib.contextmanager
152
152
  def cwd(new_dir: PathLike) -> Generator[PathLike, None, None]:
153
+ """Context manager to temporarily change directory. Not reentrant."""
153
154
  old_dir = os.getcwd()
154
155
  os.chdir(new_dir)
155
156
  try:
@@ -158,6 +159,20 @@ def cwd(new_dir: PathLike) -> Generator[PathLike, None, None]:
158
159
  os.chdir(old_dir)
159
160
 
160
161
 
162
+ @contextlib.contextmanager
163
+ def patch_env(name: str, value: str) -> Generator[None, None, None]:
164
+ """Context manager to temporarily patch an environment variable."""
165
+ old_value = os.getenv(name)
166
+ os.environ[name] = value
167
+ try:
168
+ yield
169
+ finally:
170
+ if old_value is None:
171
+ del os.environ[name]
172
+ else:
173
+ os.environ[name] = old_value
174
+
175
+
161
176
  def rmtree(path: PathLike) -> None:
162
177
  """Remove the given recursively.
163
178
 
@@ -935,7 +950,7 @@ class LockFile(object):
935
950
  )
936
951
 
937
952
  try:
938
- with open(lock_file, mode='w'):
953
+ with open(lock_file, mode="w"):
939
954
  pass
940
955
  except OSError as e:
941
956
  raise IOError(str(e)) from e