diff --git a/readthedocs/vcs_support/backends/git.py b/readthedocs/vcs_support/backends/git.py index 6c6e3077dbd..0176e896afe 100644 --- a/readthedocs/vcs_support/backends/git.py +++ b/readthedocs/vcs_support/backends/git.py @@ -15,8 +15,7 @@ import git from builtins import str from django.core.exceptions import ValidationError -from django.conf import settings -from git.exc import BadName +from git.exc import BadName, InvalidGitRepositoryError from readthedocs.config import ALL from readthedocs.projects.exceptions import RepositoryError @@ -67,8 +66,11 @@ def update(self): return self.clone() def repo_exists(self): - code, _, _ = self.run('git', 'status', record=False) - return code == 0 + try: + git.Repo(self.working_dir) + except InvalidGitRepositoryError: + return False + return True def are_submodules_available(self, config): """Test whether git submodule checkout step should be performed.""" @@ -83,8 +85,8 @@ def are_submodules_available(self, config): return False # Keep compatibility with previous projects - code, out, _ = self.run('git', 'submodule', 'status', record=False) - return code == 0 and bool(out) + repo = git.Repo(self.working_dir) + return bool(repo.submodules) def validate_submodules(self, config): """