Skip to content

Commit

Permalink
Merge pull request #4993 from stsewd/remove-local-git-branches
Browse files Browse the repository at this point in the history
Remove `LOCAL_GIT_BRANCHES` from settings
  • Loading branch information
ericholscher authored Dec 13, 2018
2 parents cd6e821 + 311373c commit 00303bb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
42 changes: 38 additions & 4 deletions readthedocs/rtd_tests/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import django_dynamic_fixture as fixture
import pytest
import six
from django.contrib.auth.models import User
from mock import Mock, patch

Expand Down Expand Up @@ -49,7 +50,8 @@ def setUp(self):
self.dummy_conf.submodules.include = ALL
self.dummy_conf.submodules.exclude = []

def test_git_branches(self):
@patch('readthedocs.projects.models.Project.checkout_path')
def test_git_branches(self, checkout_path):
repo_path = self.project.repo
default_branches = [
# comes from ``make_test_git`` function
Expand All @@ -63,15 +65,47 @@ def test_git_branches(self):
'2.0.X',
'release/2.0.0',
'release/foo/bar',
]
for branch in branches:
create_git_branch(repo_path, branch)

# Create dir where to clone the repo
local_repo = os.path.join(mkdtemp(), 'local')
os.mkdir(local_repo)
checkout_path.return_value = local_repo

repo = self.project.vcs_repo()
repo.clone()

self.assertEqual(
set(branches + default_branches),
{branch.verbose_name for branch in repo.branches},
)

@pytest.mark.skipif(six.PY2, reason='Only for python3')
@patch('readthedocs.projects.models.Project.checkout_path')
def test_git_branches_unicode(self, checkout_path):
repo_path = self.project.repo
default_branches = [
# comes from ``make_test_git`` function
'submodule',
'relativesubmodule',
'invalidsubmodule',
]
branches = [
'master',
'release-ünîø∂é',
]
for branch in branches:
create_git_branch(repo_path, branch)

# Create dir where to clone the repo
local_repo = os.path.join(mkdtemp(), 'local')
os.mkdir(local_repo)
checkout_path.return_value = local_repo

repo = self.project.vcs_repo()
# We aren't cloning the repo,
# so we need to hack the repo path
repo.working_dir = repo_path
repo.clone()

self.assertEqual(
set(branches + default_branches),
Expand Down
12 changes: 10 additions & 2 deletions readthedocs/rtd_tests/tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ def test_sync_repository(self):
@patch('readthedocs.projects.tasks.api_v2')
@patch('readthedocs.projects.models.Project.checkout_path')
def test_check_duplicate_reserved_version_latest(self, checkout_path, api_v2):
checkout_path.return_value = self.project.repo
create_git_branch(self.repo, 'latest')
create_git_tag(self.repo, 'latest')

# Create dir where to clone the repo
local_repo = os.path.join(mkdtemp(), 'local')
os.mkdir(local_repo)
checkout_path.return_value = local_repo

version = self.project.versions.get(slug=LATEST)
sync_repository = tasks.UpdateDocsTaskStep()
sync_repository.version = version
Expand All @@ -148,10 +152,14 @@ def test_check_duplicate_reserved_version_latest(self, checkout_path, api_v2):
@patch('readthedocs.projects.tasks.api_v2')
@patch('readthedocs.projects.models.Project.checkout_path')
def test_check_duplicate_reserved_version_stable(self, checkout_path, api_v2):
checkout_path.return_value = self.project.repo
create_git_branch(self.repo, 'stable')
create_git_tag(self.repo, 'stable')

# Create dir where to clone the repo
local_repo = os.path.join(mkdtemp(), 'local')
os.mkdir(local_repo)
checkout_path.return_value = local_repo

version = self.project.versions.get(slug=LATEST)
sync_repository = tasks.UpdateDocsTaskStep()
sync_repository.version = version
Expand Down
1 change: 0 additions & 1 deletion readthedocs/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CommunityTestSettings(CommunityDevSettings):

DEBUG = False
TEMPLATE_DEBUG = False
LOCAL_GIT_BRANCHES = True

@property
def LOGGING(self): # noqa - avoid pep8 N802
Expand Down
2 changes: 0 additions & 2 deletions readthedocs/vcs_support/backends/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ def branches(self):
# ``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
Expand Down

0 comments on commit 00303bb

Please sign in to comment.