diff --git a/readthedocs/settings/test.py b/readthedocs/settings/test.py index f49dc8584b1..398f8664b7e 100644 --- a/readthedocs/settings/test.py +++ b/readthedocs/settings/test.py @@ -16,6 +16,7 @@ class CommunityTestSettings(CommunityDevSettings): DEBUG = False TEMPLATE_DEBUG = False + LOCAL_GIT_BRANCHES = True @property def LOGGING(self): # noqa - avoid pep8 N802 diff --git a/readthedocs/vcs_support/backends/git.py b/readthedocs/vcs_support/backends/git.py index 32e711a7e7d..8da10bb4617 100644 --- a/readthedocs/vcs_support/backends/git.py +++ b/readthedocs/vcs_support/backends/git.py @@ -15,6 +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 readthedocs.config import ALL @@ -177,12 +178,13 @@ def tags(self): def branches(self): repo = git.Repo(self.working_dir) versions = [] + branches = [] - # ``repo.branches`` returns local branches and - branches = repo.branches # ``repo.remotes.origin.refs`` returns remote branches if repo.remotes: branches += repo.remotes.origin.refs + if getattr(settings, 'LOCAL_GIT_BRANCHES', False): + branches += repo.branches for branch in branches: verbose_name = branch.name