Skip to content

Commit 90dc03d

Browse files
committed
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.
1 parent 79a36a5 commit 90dc03d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

‎git/cmd.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ def refresh(cls, path=None):
203203
"""
204204
# discern which path to refresh with
205205
if path is not None:
206-
new_git = os.path.abspath(path)
206+
new_git = os.path.expanduser(path)
207+
new_git = os.path.abspath(new_git)
207208
else:
208209
new_git = os.environ.get(cls._git_exec_env_var, cls.git_exec_name)
209210

@@ -212,14 +213,23 @@ def refresh(cls, path=None):
212213
cls.GIT_PYTHON_GIT_EXECUTABLE = new_git
213214

214215
# test if the new git executable path is valid
216+
217+
if sys.version_info < (3,):
218+
# - a GitCommandNotFound error is spawned by ourselves
219+
# - a OSError is spawned if the git executable provided
220+
# cannot be executed for whatever reason
221+
exceptions = (GitCommandNotFound, OSError)
222+
else:
223+
# - a GitCommandNotFound error is spawned by ourselves
224+
# - a PermissionError is spawned if the git executable provided
225+
# cannot be executed for whatever reason
226+
exceptions = (GitCommandNotFound, PermissionError)
227+
215228
has_git = False
216229
try:
217230
cls().version()
218231
has_git = True
219-
except (GitCommandNotFound, PermissionError):
220-
# - a GitCommandNotFound error is spawned by ourselves
221-
# - a PermissionError is spawned if the git executable provided
222-
# cannot be executed for whatever reason
232+
except exceptions:
223233
pass
224234

225235
# warn or raise exception if test failed

0 commit comments

Comments
 (0)