Commit 6738f829 by Sébastien Eustace

Fix errors when git could not be found

parent f3017b30
......@@ -32,6 +32,7 @@
- Fixed detection of `.egg-info` directory for non-poetry projects. (Thanks to [@gtors](https://github.com/gtors))
- Fixed only-wheel builds. (Thanks to [@gtors](https://github.com/gtors))
- Fixed key and array order in lock file to avoid having differences when relocking.
- Fixed errors when `git` could not be found.
## [0.10.3] - 2018-06-04
......
import subprocess
import warnings
from poetry.utils._compat import Path
from .git import Git
......@@ -8,4 +11,12 @@ def get_vcs(directory): # type: (Path) -> Git
for p in [directory] + list(directory.parents):
if (p / ".git").is_dir():
return Git(p)
try:
return Git(p)
except (subprocess.CalledProcessError, OSError):
# Either git could not be found or does not exist
warnings.warn(
"git executable could not be found", category=RuntimeWarning
)
return
......@@ -7,7 +7,7 @@ from poetry.utils._compat import decode
class GitConfig:
def __init__(self):
def __init__(self, requires_git_presence=False):
self._config = {}
try:
......@@ -22,7 +22,8 @@ class GitConfig:
for group in m:
self._config[group[0]] = group[1]
except (subprocess.CalledProcessError, OSError):
pass
if requires_git_presence:
raise
def get(self, key, default=None):
return self._config.get(key, default)
......@@ -33,7 +34,7 @@ class GitConfig:
class Git:
def __init__(self, work_dir=None):
self._config = GitConfig()
self._config = GitConfig(requires_git_presence=True)
self._work_dir = work_dir
@property
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment