Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

__init__: don't run refresh on import#2073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
lheckemann wants to merge1 commit intogitpython-developers:main
base:main
Choose a base branch
Loading
fromlheckemann:push-stqopxmnmomy
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletionsdoc/source/changes.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,19 @@
Changelog
=========

4.0.0
=====

GitPython will no longer throw an ImportError when no git executable can
be found at import time. Instead, errors are deferred until the first
attempt at using it. Consumers with special handling for
the old ImportError behaviour should instead call `git.refresh` and handle
GitCommandNotFoundErrors themselves.

See the following for all changes.
https://github.com/gitpython-developers/GitPython/releases/tag/4.0.0


3.1.45
======

Expand Down
5 changes: 0 additions & 5 deletionsgit/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -292,9 +292,4 @@ def refresh(path: Optional[PathLike] = None) -> None:
GIT_OK = True


try:
refresh()
except Exception as _exc:
raise ImportError("Failed to initialize: {0}".format(_exc)) from _exc

# } END initialize git executable path
4 changes: 3 additions & 1 deletiongit/cmd.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -857,7 +857,7 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
if mode in warn:
_logger.critical(err)
else:
raiseImportError(err)
raiseGitCommandNotFound(new_git,err)
else:
err = dedent(
"""\
Expand DownExpand Up@@ -1575,6 +1575,8 @@ def _call_process(
default (especially ``as_process = False``, ``stdout_as_string = True``) and
return :class:`str`.
"""
if not self.GIT_PYTHON_GIT_EXECUTABLE:
self.refresh()
# Handle optional arguments prior to calling transform_kwargs.
# Otherwise these'll end up in args, which is bad.
exec_kwargs = {k: v for k, v in kwargs.items() if k in execute_kwargs}
Expand Down
4 changes: 4 additions & 0 deletionstest/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,3 +2,7 @@
#
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
#
import git

git.refresh()
2 changes: 1 addition & 1 deletiontest/test_git.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -434,7 +434,7 @@ def test_initial_refresh_from_bad_git_path_env_error(self, case):
Git.GIT_PYTHON_GIT_EXECUTABLE = None # Simulate startup.

with mock.patch.dict(os.environ, env_vars):
with self.assertRaisesRegex(ImportError, r"\ABad git executable.\n"):
with self.assertRaisesRegex(GitCommandNotFound, r"Bad git executable."):
refresh()

def test_initial_refresh_from_good_absolute_git_path_env(self):
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp