git: use bool condition to check if the git path is fine. Using exceptions

spams the logs with confusing tracebacks.
This commit is contained in:
Marcin Kuzminski 2017-12-18 15:31:48 +01:00
parent 81d17e2b3f
commit fad0fcf1c3
3 changed files with 7 additions and 3 deletions

View file

@ -163,7 +163,11 @@ class GitRepository(BaseRepository):
else:
self._remote.init()
else:
self._remote.assert_correct_path()
if not self._remote.assert_correct_path():
raise RepositoryError(
'Path "%s" does not contain a Git repository' %
(self.path,))
# TODO: johbo: check if we have to translate the OSError here
except OSError as err:
raise RepositoryError(err)

View file

@ -85,7 +85,7 @@ class TestGitRepository:
return GitRepository(next(REPO_PATH_GENERATOR), create=True, bare=bare)
def test_wrong_repo_path(self):
wrong_repo_path = '/tmp/errorrepo'
wrong_repo_path = '/tmp/errorrepo_git'
with pytest.raises(RepositoryError):
GitRepository(wrong_repo_path)

View file

@ -79,7 +79,7 @@ class TestMercurialRepository:
return MercurialRepository(next(REPO_PATH_GENERATOR), create=True)
def test_wrong_repo_path(self):
wrong_repo_path = '/tmp/errorrepo'
wrong_repo_path = '/tmp/errorrepo_hg'
with pytest.raises(RepositoryError):
MercurialRepository(wrong_repo_path)