Skip to content

Commit dfbe6df

Browse files
authored
Merge pull request #5002 from stsewd/use-git-python
Replace git status and git submodules status for gitpython
2 parents 2796e15 + 93c031b commit dfbe6df

File tree

1 file changed

+8
-6
lines changed
  • readthedocs/vcs_support/backends

1 file changed

+8
-6
lines changed

readthedocs/vcs_support/backends/git.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
import git
1616
from builtins import str
1717
from django.core.exceptions import ValidationError
18-
from django.conf import settings
19-
from git.exc import BadName
18+
from git.exc import BadName, InvalidGitRepositoryError
2019

2120
from readthedocs.config import ALL
2221
from readthedocs.projects.exceptions import RepositoryError
@@ -67,8 +66,11 @@ def update(self):
6766
return self.clone()
6867

6968
def repo_exists(self):
70-
code, _, _ = self.run('git', 'status', record=False)
71-
return code == 0
69+
try:
70+
git.Repo(self.working_dir)
71+
except InvalidGitRepositoryError:
72+
return False
73+
return True
7274

7375
def are_submodules_available(self, config):
7476
"""Test whether git submodule checkout step should be performed."""
@@ -83,8 +85,8 @@ def are_submodules_available(self, config):
8385
return False
8486

8587
# Keep compatibility with previous projects
86-
code, out, _ = self.run('git', 'submodule', 'status', record=False)
87-
return code == 0 and bool(out)
88+
repo = git.Repo(self.working_dir)
89+
return bool(repo.submodules)
8890

8991
def validate_submodules(self, config):
9092
"""

0 commit comments

Comments
 (0)