Skip to content

Feature flag: remove DONT_SHALLOW_CLONE #10588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,6 @@ def add_features(sender, **kwargs):
SKIP_SPHINX_HTML_THEME_PATH = "skip_sphinx_html_theme_path"
MKDOCS_THEME_RTD = "mkdocs_theme_rtd"
API_LARGE_DATA = "api_large_data"
DONT_SHALLOW_CLONE = "dont_shallow_clone"
UPDATE_CONDA_STARTUP = "update_conda_startup"
CONDA_APPEND_CORE_REQUIREMENTS = "conda_append_core_requirements"
ALL_VERSIONS_IN_HTML_CONTEXT = "all_versions_in_html_context"
Expand Down Expand Up @@ -1963,10 +1962,6 @@ def add_features(sender, **kwargs):
MKDOCS_THEME_RTD,
_("MkDocs: Use Read the Docs theme for MkDocs as default theme"),
),
(
DONT_SHALLOW_CLONE,
_("Build: Do not shallow clone when cloning git repos"),
),
(
API_LARGE_DATA,
_("Build: Try alternative method of posting large data"),
Expand Down
13 changes: 0 additions & 13 deletions readthedocs/rtd_tests/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,6 @@ def test_skip_submodule_checkout(self):
repo.checkout('submodule')
self.assertTrue(repo.are_submodules_available(self.dummy_conf))

def test_use_shallow_clone(self):
repo = self.project.vcs_repo(environment=self.build_environment)
repo.update()
repo.checkout('submodule')
self.assertTrue(repo.use_shallow_clone())
fixture.get(
Feature,
projects=[self.project],
feature_id=Feature.DONT_SHALLOW_CLONE,
)
self.assertTrue(self.project.has_feature(Feature.DONT_SHALLOW_CLONE))
self.assertFalse(repo.use_shallow_clone())

def test_check_submodule_urls(self):
repo = self.project.vcs_repo(environment=self.build_environment)
repo.update()
Expand Down
34 changes: 12 additions & 22 deletions readthedocs/vcs_support/backends/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,27 +330,20 @@ def validate_submodules(self, config):
return False, invalid_submodules
return True, submodules.keys()

def use_shallow_clone(self):
"""
Test whether shallow clone should be performed.

.. note::

Temporarily, we support skipping this option as builds that rely on
git history can fail if using shallow clones. This should
eventually be configurable via the web UI.
"""
from readthedocs.projects.models import Feature
return not self.project.has_feature(Feature.DONT_SHALLOW_CLONE)

def fetch(self):
# --force lets us checkout branches that are not fast-forwarded
# https://github.com/readthedocs/readthedocs.org/issues/6097
cmd = ['git', 'fetch', 'origin',
'--force', '--tags', '--prune', '--prune-tags']

if self.use_shallow_clone():
cmd.extend(['--depth', str(self.repo_depth)])
cmd = [
"git",
"fetch",
"origin",
"--force",
"--tags",
"--prune",
"--prune-tags",
"--depth",
str(self.repo_depth),
]

if self.verbose_name and self.version_type == EXTERNAL:

Expand Down Expand Up @@ -378,10 +371,7 @@ def checkout_revision(self, revision):

def clone(self):
"""Clones the repository."""
cmd = ['git', 'clone', '--no-single-branch']

if self.use_shallow_clone():
cmd.extend(['--depth', str(self.repo_depth)])
cmd = ["git", "clone", "--no-single-branch", "--depth", str(self.repo_depth)]

cmd.extend([self.repo_url, '.'])

Expand Down