Skip to content
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

Shallow git clone #4939

Merged
merged 2 commits into from
Dec 4, 2018
Merged
Changes from all commits
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
7 changes: 5 additions & 2 deletions readthedocs/vcs_support/backends/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Backend(BaseVCS):
supports_branches = True
supports_submodules = True
fallback_branch = 'master' # default branch
repo_depth = 50

def __init__(self, *args, **kwargs):
super(Backend, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -131,7 +132,8 @@ def validate_submodules(self, config):

def fetch(self):
code, stdout, stderr = self.run(
'git', 'fetch', '--tags', '--prune', '--prune-tags',
'git', 'fetch', '--depth', str(self.repo_depth),
'--tags', '--prune', '--prune-tags',
)
if code != 0:
raise RepositoryError
Expand All @@ -150,7 +152,8 @@ def checkout_revision(self, revision=None):
def clone(self):
"""Clones the repository."""
code, stdout, stderr = self.run(
'git', 'clone', self.repo_url, '.'
'git', 'clone', '--depth', str(self.repo_depth),
'--no-single-branch', self.repo_url, '.'
)
if code != 0:
raise RepositoryError
Expand Down