| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,11 @@ Changelog | |||
| 12 | 12 | these operations to never raise. However, that behavious is undesirable as it would effectively hide the fact that there | |
| 13 | 13 | was an error. See `this issue <https://github.com/gitpython-developers/GitPython/issues/271>`_ for more information. | |
| 14 | 14 | ||
| 15 | + * If the git executable can't be found in the PATH or at the path provided by `GIT_PYTHON_GIT_EXECUTABLE`, this is made | ||
| 16 | + obvious by throwing `GitCommandNotFound`, both on unix and on windows. | ||
| 17 | + | ||
| 18 | + - Those who support **GUI on windows** will now have to set `git.Git.USE_SHELL = True` to get the previous behaviour. | ||
| 19 | + | ||
| 15 | 20 | 0.3.6 - Features | |
| 16 | 21 | ================ | |
| 17 | 22 | * **DOCS** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,7 +26,10 @@ | |||
| 26 | 26 | stream_copy, | |
| 27 | 27 | WaitGroup | |
| 28 | 28 | ) | |
| 29 | - from .exc import GitCommandError | ||
| 29 | + from .exc import ( | ||
| 30 | + GitCommandError, | ||
| 31 | + GitCommandNotFound | ||
| 32 | + ) | ||
| 30 | 33 | from git.compat import ( | |
| 31 | 34 | string_types, | |
| 32 | 35 | defenc, | |
@@ -241,6 +244,12 @@ class Git(LazyMixin): | |||
| 241 | 244 | _git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE" | |
| 242 | 245 | GIT_PYTHON_GIT_EXECUTABLE = os.environ.get(_git_exec_env_var, git_exec_name) | |
| 243 | 246 | ||
| 247 | + # If True, a shell will be used when executing git commands. | ||
| 248 | + # This should only be desirable on windows, see https://github.com/gitpython-developers/GitPython/pull/126 | ||
| 249 | + # for more information | ||
| 250 | + # Override this value using `Git.USE_SHELL = True` | ||
| 251 | + USE_SHELL = False | ||
| 252 | + | ||
| 244 | 253 | class AutoInterrupt(object): | |
| 245 | 254 | ||
| 246 | 255 | """Kill/Interrupt the stored process instance once this instance goes out of scope. It is | |
@@ -543,18 +552,29 @@ def execute(self, command, | |||
| 543 | 552 | env["LC_MESSAGES"] = "C" | |
| 544 | 553 | env.update(self._environment) | |
| 545 | 554 | ||
| 546 | - proc = Popen(command, | ||
| 547 | - env=env, | ||
| 548 | - cwd=cwd, | ||
| 549 | - stdin=istream, | ||
| 550 | - stderr=PIPE, | ||
| 551 | - stdout=PIPE, | ||
| 552 | - # Prevent cmd prompt popups on windows by using a shell ... . | ||
| 553 | - # See https://github.com/gitpython-developers/GitPython/pull/126 | ||
| 554 | - shell=sys.platform == 'win32', | ||
| 555 | - close_fds=(os.name == 'posix'), # unsupported on windows | ||
| 556 | - **subprocess_kwargs | ||
| 557 | - ) | ||
| 555 | + if sys.platform == 'win32': | ||
| 556 | + cmd_not_found_exception = WindowsError | ||
| 557 | + else: | ||
| 558 | + if sys.version_info[0] > 2: | ||
| 559 | + cmd_not_found_exception = FileNotFoundError # NOQA # this is defined, but flake8 doesn't know | ||
| 560 | + else: | ||
| 561 | + cmd_not_found_exception = OSError | ||
| 562 | + # end handle | ||
| 563 | + | ||
| 564 | + try: | ||
| 565 | + proc = Popen(command, | ||
| 566 | + env=env, | ||
| 567 | + cwd=cwd, | ||
| 568 | + stdin=istream, | ||
| 569 | + stderr=PIPE, | ||
| 570 | + stdout=PIPE, | ||
| 571 | + shell=self.USE_SHELL, | ||
| 572 | + close_fds=(os.name == 'posix'), # unsupported on windows | ||
| 573 | + **subprocess_kwargs | ||
| 574 | + ) | ||
| 575 | + except cmd_not_found_exception as err: | ||
| 576 | + raise GitCommandNotFound(str(err)) | ||
| 577 | + | ||
| 558 | 578 | if as_process: | |
| 559 | 579 | return self.AutoInterrupt(proc, command) | |
| 560 | 580 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,12 @@ class NoSuchPathError(OSError): | |||
| 18 | 18 | """ Thrown if a path could not be access by the system. """ | |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + class GitCommandNotFound(Exception): | ||
| 22 | + """Thrown if we cannot find the `git` executable in the PATH or at the path given by | ||
| 23 | + the GIT_PYTHON_GIT_EXECUTABLE environment variable""" | ||
| 24 | + pass | ||
| 25 | + | ||
| 26 | + | ||
| 21 | 27 | class GitCommandError(Exception): | |
| 22 | 28 | """ Thrown if execution of the git command fails with non-zero status code. """ | |
| 23 | 29 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments