From b56d6778ee678081e22c1897ede1314ff074122a Mon Sep 17 00:00:00 2001 From: "Odegard, Ken" Date: Sun, 9 Jul 2017 22:44:19 +0200 Subject: Added ability to silence initial warning Added the ability to silence the first refresh warning upon import by setting an environment variable. --- git/cmd.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 0e9315a2..ae7721df 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -231,10 +231,19 @@ class Git(LazyMixin): # None) we only warn the user and simply set the default # executable cls.GIT_PYTHON_GIT_EXECUTABLE = cls.git_exec_name - print(dedent("""\ - WARNING: %s - All git commands will error until this is rectified. - """) % err) + + # test if the user didn't want a warning + nowarn = os.environ.get("GIT_PYTHON_NOWARN", "false") + nowarn = nowarn.lower() in ["t", "true", "y", "yes"] + + if not nowarn: + print(dedent("""\ + WARNING: %s + All git commands will error until this is rectified. + + This initial warning can be silenced in the future by setting the environment variable: + export GIT_PYTHON_NOWARN=true + """) % err) else: # after the first setup (when GIT_PYTHON_GIT_EXECUTABLE # is no longer None) we raise an exception and reset the -- cgit v1.2.1