-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add temporary method for disabling shallow cloning (#5031) #5036
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,11 +131,26 @@ def validate_submodules(self, config): | |
return False, [] | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we can remove this note if we go for using a feature flag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My thinking was to include this for now so we can unblock the broken builds then decide at a later date whether we wanted to expose this to users. If we don't, we remove the note. If we do, we remove all of this code. |
||
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): | ||
code, stdout, stderr = self.run( | ||
'git', 'fetch', '--depth', str(self.repo_depth), | ||
'--tags', '--prune', '--prune-tags', | ||
) | ||
cmd = ['git', 'fetch', '--tags', '--prune', '--prune-tags'] | ||
|
||
if self.use_shallow_clone(): | ||
cmd.extend(['--depth', str(self.repo_depth)]) | ||
|
||
code, stdout, stderr = self.run(*cmd) | ||
if code != 0: | ||
raise RepositoryError | ||
return code, stdout, stderr | ||
|
@@ -152,10 +167,14 @@ def checkout_revision(self, revision=None): | |
|
||
def clone(self): | ||
"""Clones the repository.""" | ||
code, stdout, stderr = self.run( | ||
'git', 'clone', '--depth', str(self.repo_depth), | ||
'--no-single-branch', self.repo_url, '.' | ||
) | ||
cmd = ['git', 'clone', '--no-single-branch'] | ||
|
||
if self.use_shallow_clone(): | ||
cmd.extend(['--depth', str(self.repo_depth)]) | ||
|
||
cmd.extend([self.repo_url, '.']) | ||
|
||
code, stdout, stderr = self.run(*cmd) | ||
if code != 0: | ||
raise RepositoryError | ||
return code, stdout, stderr | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to call
.clone
(mocked) here and check what were the arguments used to call it. That way, we are sure that we are usinguse_shallow_clone
and it does have an effect in the flow.