summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOdegard, Ken <ken.odegard@gmail.com>2017-07-26 07:52:16 -0500
committerOdegard, Ken <ken.odegard@gmail.com>2017-07-26 07:52:16 -0500
commit90dc03da3ebe1daafd7f39d1255565b5c07757cb (patch)
tree11b8fa14ccd92a49bbd4992eaba5828840434079
parent79a36a54b8891839b455c2f39c5d7bc4331a4e03 (diff)
downloadgitpython-90dc03da3ebe1daafd7f39d1255565b5c07757cb.tar.gz
Minor bug fixes
Added tilde expansion as part of the refresh function. Added python version check such that we properly capture PermissionError in Python >=3 and OSError in Python <3.
-rw-r--r--git/cmd.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/git/cmd.py b/git/cmd.py
index 329ad434..232450cb 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -203,7 +203,8 @@ class Git(LazyMixin):
"""
# discern which path to refresh with
if path is not None:
- new_git = os.path.abspath(path)
+ new_git = os.path.expanduser(path)
+ new_git = os.path.abspath(new_git)
else:
new_git = os.environ.get(cls._git_exec_env_var, cls.git_exec_name)
@@ -212,14 +213,23 @@ class Git(LazyMixin):
cls.GIT_PYTHON_GIT_EXECUTABLE = new_git
# test if the new git executable path is valid
+
+ if sys.version_info < (3,):
+ # - a GitCommandNotFound error is spawned by ourselves
+ # - a OSError is spawned if the git executable provided
+ # cannot be executed for whatever reason
+ exceptions = (GitCommandNotFound, OSError)
+ else:
+ # - a GitCommandNotFound error is spawned by ourselves
+ # - a PermissionError is spawned if the git executable provided
+ # cannot be executed for whatever reason
+ exceptions = (GitCommandNotFound, PermissionError)
+
has_git = False
try:
cls().version()
has_git = True
- except (GitCommandNotFound, PermissionError):
- # - a GitCommandNotFound error is spawned by ourselves
- # - a PermissionError is spawned if the git executable provided
- # cannot be executed for whatever reason
+ except exceptions:
pass
# warn or raise exception if test failed