Speed up cloning by using a depth of 1 if there is no refspec
To speed up cloning a repository, a shallow clone containing just the
last commit can be made, but *only* if no refspec is provided.
MODIFY
repo2docker/app.py
repo2docker/app.py
@@ -167,8 +167,11 @@ class Repo2Docker(Application):
def fetch(self, url, ref, checkout_path):
"""Check out a repo using url and ref to the checkout_path location"""
try:
- for line in execute_cmd(['git', 'clone', '--recursive', url, checkout_path],
- capture=self.json_logs):
+ cmd = ['git', 'clone', '--recursive']
+ if not ref:
+ cmd.extend(['--depth', '1'])
+ cmd.extend([url, checkout_path])
+ for line in execute_cmd(cmd, capture=self.json_logs):
self.log.info(line, extra=dict(phase='fetching'))
except subprocess.CalledProcessError:
self.log.error('Failed to clone repository!',

Speed up cloning by using a depth of 1 if there is no refspec

To speed up cloning a repository, a shallow clone containing just the
last commit can be made, but *only* if no refspec is provided.