Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b56d677

Browse files
committed
Added ability to silence initial warning
Added the ability to silence the first refresh warning upon import by setting an environment variable.
1 parent e8cb31d commit b56d677

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

git/cmd.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,19 @@ def refresh(cls, path=None):
231231
# None) we only warn the user and simply set the default
232232
# executable
233233
cls.GIT_PYTHON_GIT_EXECUTABLE = cls.git_exec_name
234-
print(dedent("""\
235-
WARNING: %s
236-
All git commands will error until this is rectified.
237-
""") % err)
234+
235+
# test if the user didn't want a warning
236+
nowarn = os.environ.get("GIT_PYTHON_NOWARN", "false")
237+
nowarn = nowarn.lower() in ["t", "true", "y", "yes"]
238+
239+
if not nowarn:
240+
print(dedent("""\
241+
WARNING: %s
242+
All git commands will error until this is rectified.
243+
244+
This initial warning can be silenced in the future by setting the environment variable:
245+
export GIT_PYTHON_NOWARN=true
246+
""") % err)
238247
else:
239248
# after the first setup (when GIT_PYTHON_GIT_EXECUTABLE
240249
# is no longer None) we raise an exception and reset the

0 commit comments

Comments
 (0)