summaryrefslogtreecommitdiff
path: root/git/cmd.py
diff options
context:
space:
mode:
authorOdegard, Ken <ken.odegard@gmail.com>2017-07-09 22:44:19 +0200
committerOdegard, Ken <ken.odegard@gmail.com>2017-07-09 22:44:19 +0200
commitb56d6778ee678081e22c1897ede1314ff074122a (patch)
treedb1371fd57edecb15a41e8ad099536856d22bd82 /git/cmd.py
parente8cb31db6b3970d1e983f10b0e0b5eeda8348c7e (diff)
downloadgitpython-b56d6778ee678081e22c1897ede1314ff074122a.tar.gz
Added ability to silence initial warning
Added the ability to silence the first refresh warning upon import by setting an environment variable.
Diffstat (limited to 'git/cmd.py')
-rw-r--r--git/cmd.py17
1 files changed, 13 insertions, 4 deletions
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