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 #1808.
  • Loading branch information
EliahKagan committed Jan 26, 2024
1 parent bc42ee5 commit dc62096
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,14 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
# following values:
#
# 0|q|quiet|s|silence|n|none
# 1|w|warn|warning
# 2|r|raise|e|error
# 1|w|warn|warning|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"]
warn = ["warn", "w", "warning", "log", "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 ERROR, 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.error("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 ERROR, displayed by default)
- %s: for a raised exception
"""
)
Expand Down

0 comments on commit dc62096

Please sign in to comment.