Skip to content

Commit

Permalink
Have initial refresh use a logger to warn
Browse files Browse the repository at this point in the history
For gitpython-developers#1808.

See ac50d8e for details on the changes.
  • Loading branch information
EliahKagan committed Feb 2, 2024
1 parent ac50d8e commit 3a6e3ef
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,15 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
# expect GIT_PYTHON_REFRESH to either be unset or be one of the
# following values:
#
# 0|q|quiet|s|silence|n|none
# 1|w|warn|warning
# 2|r|raise|e|error
# 0|q|quiet|s|silence|silent|n|none
# 1|w|warn|warning|l|log
# 2|r|raise|e|error|exception

mode = os.environ.get(cls._refresh_env_var, "raise").lower()

quiet = ["quiet", "q", "silence", "s", "none", "n", "0"]
warn = ["warn", "w", "warning", "1"]
error = ["error", "e", "raise", "r", "2"]
quiet = ["quiet", "q", "silence", "s", "silent", "none", "n", "0"]
warn = ["warn", "w", "warning", "log", "l", "1"]
error = ["error", "e", "exception", "raise", "r", "2"]

if mode in quiet:
pass
Expand All @@ -428,10 +428,10 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
%s
All git commands will error until this is rectified.
This initial warning can be silenced or aggravated in the future by setting the
This initial message can be silenced or aggravated in the future by setting the
$%s environment variable. Use one of the following values:
- %s: for no warning or exception
- %s: for a printed warning
- %s: for no message or exception
- %s: for a warning message (logged at level CRITICAL, displayed by default)
- %s: for a raised exception
Example:
Expand All @@ -450,7 +450,7 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
)

if mode in warn:
print("WARNING: %s" % err)
_logger.critical("WARNING: %s", err)
else:
raise ImportError(err)
else:
Expand All @@ -460,8 +460,8 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
%s environment variable has been set but it has been set with an invalid value.
Use only the following values:
- %s: for no warning or exception
- %s: for a printed warning
- %s: for no message or exception
- %s: for a warning message (logged at level CRITICAL, displayed by default)
- %s: for a raised exception
"""
)
Expand Down

0 comments on commit 3a6e3ef

Please sign in to comment.